Moon and Sun

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Let SS be a non-empty sequence of integers and KK be a positive integer. The functions moon()moon() and sun()sun() 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(S_1S,K)={Sif K=1 sun(moon(S_1S),K1)if K>1sun\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(\[2,7])=\[5]moon(\[2, 7]) = \[5].
  • moon(\[4,1,0,7,2])=\[3,1,7,5]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]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 sun(S_1S,S)sun\left(S\_{1\dots |S|}, |S|\right) is always a sequence with exactly one element.

You are given a sequence of NN integers A_1NA\_{1\dots N}. An index i=\[1N]i = \[1\dots N] is hot if and only if there exists a sequence A_1NA'\_{1\dots N} satisfying the following conditions.

  • A_iA_iA'\_i \ne A\_i and A_iA\_i' is an integer between 100000-100 000 and 100000100 000, inclusive;
  • A_j=A_jA'\_j = A\_j for all jij \ne i;
  • The only element in sun(A_1N,N)sun\left(A'\_{1\dots N}, N\right) is a multiple of 235813235 813.

Your task in this problem is to count the number of hot indices in a given A_1NA\_{1\dots N}.

For example, there are 33 hot indices in A_15=\[4,1,0,7,2]A\_{1\dots 5} = \[4, 1, 0, 7, 2], which are 1,3,5\\{1, 3, 5\\}.

  • i = 1 \~\~ A'\_1 = 30 \rightarrow A'\_{1\dots5} = \[30, 1, 0, 7, 2] \rightarrow sun(\[30, 1, 0, 7, 2], 5) = \[0]
  • 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]
  • i = 5 \~\~ A'\_1 = 28 \rightarrow A'\_{1\dots5} = \[4, 1, 0, 7, 28] \rightarrow sun(\[4, 1, 0, 7, 28], 5) = \[0]

Note that both 00 and 471626-471 626 are multiples of 235813235 813. On the other hand, the index i=2i = 2 is not hot as there does not exist an integer A_2A_2A'\_2 \ne A\_2 between 100000-100 000 and 100000100 000, inclusive, such that the only element in sun(A_15,5)sun(A'\_{1\dots 5} , 5) is a multiple of 235813235 813. The index i=4i = 4 is also not hot for a similar reason.

입력

Input begins with a line containing an integer: NN (1N1000001 \le N \le 100 000) representing the number of integers in AA. The next line contains NN integers: A_iA\_i (100000A_i100000-100 000 \le A\_i \le 100 000) representing the sequence of integers.

출력

Output in a line an integer representing the number of hot indices in the given A_1NA\_{1\dots N} .