Stone Game
Bessie and Elsie are playing a game with n piles of stones, where the i-th pile has a[i]
(1 ≤ a[i]
≤ 10^6
) stones for each i (1 ≤ i ≤ n). The two cows alternate turns, with Bessie going first.
First, Bessie chooses some positive integer
s[1]
and removess[1]
stones from some pile with at leasts[1]
stones.Then Elsie chooses some positive integer
s[2]
such thats[1]
dividess[2]
and removess[2]
stones from some pile with at leasts[2]
stones.Then Bessie chooses some positive integer
s[3]
such thats[2]
dividess[3]
and removess[3]
stones from some pile with at leasts[3]
stones and so on.In general,
s[i]
, the number of stones removed on turn i, must divides[i+1]
.
The first cow who is unable to remove stones on her turn loses.
Compute the number of ways Bessie can remove stones on her first turn in order to guarantee a win (meaning that there exists a strategy such that Bessie wins regardless of what choices Elsie makes). Two ways of removing stones are considered to be different if they remove a different number of stones or they remove stones from different piles.
Input
The first line contains n (1 ≤ n ≤ 10^5
).
The second line contains n integers a[1]
,..., a[n]
.
Output
Print the number of ways Bessie can remove stones on her first turn in order to guarantee a win.
Note that the large size of integers involved in this problem may require the use of 64-bit integer data types (e.g., a "long long" in C/C++).
Example 1
Bessie wins if she removes 4, 5, 6 or 7 stones from the only pile. Then the game terminates immediately.
Example 2
Bessie wins if she removes 2 or 3 stones from any pile. Then the two players will alternate turns removing the same number of stones, with Bessie making the last move.