- Time limit: 1.00 s
- Memory limit: 512 MB
You know that an array has integers between and , and the absolute difference between two adjacent values is at most .
Given a description of the array where some values may be unknown, your task is to count the number of arrays that match the description.
Input
The first input line has two integers and : the array size and the upper bound for each value.
The next line has integers : the contents of the array. Value denotes an unknown value.
Output
Print one integer: the number of arrays modulo .
Constraints
Example
Input:
3 5 2 0 2
Output:
3
Explanation: The arrays , and match the description.