Moon and Sun
문제
Let be a non-empty sequence of integers and be a positive integer. The functions and are defined as follows.
moon\left(S_{1\dots|S|}\right) = \begin{cases} S & \text{if } |S| = 1 \\ \left[ S_2 − S_1, S_3 − S_2, \dots , S_{|S|} − S_{|S|−1} \right] & \text{if }|S| > 1 \end{cases}
sun\left(S_{1\dots|S|}, K\right) = \begin{cases} S & \text{if } K = 1 \\ sun\left(moon\left(S_1\dots|S|\right), K − 1\right) & \text{if }K > 1 \end{cases}
For example,
- .
- moon([4, 1, 0, 7, 2]) = [−3, −1, 7, −5].
- sun([4, 1, 0, 7, 2], 5) = sun([−3, −1, 7, −5], 4) = sun([2, 8, −12], 3) = sun([6, −20], 2) = sun([−26], 1) = [−26].
Observe that is always a sequence with exactly one element.
You are given a sequence of integers . An index is hot if and only if there exists a sequence satisfying the following conditions.
- and is an integer between and , inclusive;
- for all ;
- The only element in is a multiple of .
Your task in this problem is to count the number of hot indices in a given .
For example, there are hot indices in , which are .
- i = 3 ~~ A'_1 = −78 600 \rightarrow A'_{1\dots5} = [4, 1, −78 600, 7, 2] \rightarrow sun([4, 1, −78 600, 7, 2], 5) = [−471 626]
Note that both and are multiples of . On the other hand, the index is not hot as there does not exist an integer between and , inclusive, such that the only element in is a multiple of . The index is also not hot for a similar reason.
입력
Input begins with a line containing an integer: () representing the number of integers in . The next line contains integers: () representing the sequence of integers.
출력
Output in a line an integer representing the number of hot indices in the given .
예제
예제 1
5 4 1 0 7 2
3
예제 2
4 10 20 30 -40
4
예제 3
2 100 100
0