Let S be a non-empty sequence of integers and K a positive integer. The functions moon() and sun() are defined as follows.
moon(S1…∣S∣)={S[S2−S1,S3−S2,…,S∣S∣−S∣S∣−1]if ∣S∣=1if ∣S∣>1
sun(S1…∣S∣,K)={Ssun(moon(S1…∣S∣),K−1)if K=1if K>1
For example,
- moon([2,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].
Note that sun(S1…∣S∣,∣S∣) is always a sequence with exactly one element.
You are given a sequence of N integers A1…N. An index i=[1…N] is hot if and only if there exists a sequence A1…N′ satisfying the following conditions.
- Ai′=Ai and Ai′ is an integer between −100000 and 100000, inclusive;
- Aj′=Aj for all j=i;
- The only element in sun(A1…N′,N) is a multiple of 235813.
Your task in this problem is to count the number of hot indices in a given A1…N.
For example, there are 3 hot indices in A1…5=[4,1,0,7,2], which are {1,3,5}.
- i=1, A1′=30→A1…5′=[30,1,0,7,2]→sun([30,1,0,7,2],5)=[0]
- i=3, A3′=−78600→A1…5′=[4,1,−78600,7,2]→sun([4,1,−78600,7,2],5)=[−471626]
- i=5, A5′=28→A1…5′=[4,1,0,7,28]→sun([4,1,0,7,28],5)=[0]
Both 0 and −471626 are multiples of 235813. On the other hand, the index i=2 is not hot, as there is no integer A2′=A2 between −100000 and 100000, inclusive, such that the only element in sun(A1…5′,5) is a multiple of 235813. The index i=4 is also not hot for the same reason.