#P1067A. Array Without Local Maximums
Array Without Local Maximums
Description
Ivan unexpectedly saw a present from one of his previous birthdays. It is array of numbers from to . Array is old and some numbers are hard to read. Ivan remembers that for all elements at least one of its neighbours ls not less than it, more formally:
,
and
for all from to .
Ivan does not remember the array and asks to find the number of ways to restore it. Restored elements also should be integers from to . Since the number of ways can be big, print it modulo .
First line of input contains one integer () — size of the array.
Second line of input contains integers — elements of array. Either or . means that -th element can't be read.
Print number of ways to restore the array modulo .
Input
First line of input contains one integer () — size of the array.
Second line of input contains integers — elements of array. Either or . means that -th element can't be read.
Output
Print number of ways to restore the array modulo .
Note
In the first example, only possible value of is .
In the second example, so there are different values because all restored elements should be integers between and .