You wrote your favourite
That is, given an array of adjacent sums, how many arrays of positive integers generate these sums?
Constraints
Subtask 1 [10%]
Subtask 2 [30%]
Subtask 3 [30%]
Subtask 4 [30%]
No additional constraints.
Input Specification
The first line contains the integer
The next line contains
Output Specification
Output the number of arrays of positive integers that could yield
Sample Input
Copy
4
5 4 3
Sample Output
Copy
2
Explanation
The two arrays are 2 3 1 2
and 3 2 2 1
.
Comments
For those unsure what adjacent sums mean, here's an example:
So 3=1+2, 5=2+3, etc.
In this problem, you're given the adjacent sums array and have to figure out the number of possibilities for the original array.