PivotOJ

Down the Pyramid

시간 제한: 2000ms메모리 제한: 512MB출처: GCPC 2018BOJ 16065

문제

Do you like number pyramids? Given a number sequence that represents the base, you are usually supposed to build the rest of the “pyramid” bottom-up: For each pair of adjacent numbers, you would compute their sum and write it down above them. For example, given the base sequence [1, 2, 3], the sequence directly above it would be [3, 5], and the top of the pyramid would be [8]:

However, I am not interested in completing the pyramid – instead, I would much rather go underground. Thus, for a sequence of n non-negative integers, I will write down a sequence of n + 1 non-negative integers below it such that each number in the original sequence is the sum of the two numbers I put below it. However, there may be several possible sequences or perhaps even none at all satisfying this condition. So, could you please tell me how many sequences there are for me to choose from?

입력

The input consists of:

  • one line with the integer n (1 ≤ n ≤ 106), the length of the base sequence.
  • one line with n integers a1, . . . , an (0 ≤ ai ≤ 108 for each i), forming the base sequence.

출력

Output a single integer, the number of non-negative integer sequences that would have the input sequence as the next level in a number pyramid.

예제

예제 1

입력
6
12 5 7 7 8 4
출력
2

예제 2

입력
3
10 1000 100
출력
0
코드를 제출하려면 로그인하세요.