Placeholder

#5774

Stone Game 1초 512MB

문제

Bessie and Elsie are playing a game with NN (1N1051≤N≤105) piles of stones, where the ii-th pile has aia_istones for each 1iN1≤i≤N(1ai1061≤a_i≤106). The two cows alternate turns, with Bessie going first.

First, Bessie chooses some positive integer s1s_1 and removes s1s_1 stones from some pile with at least s1s_1 stones.

Then Elsie chooses some positive integer s2s_2 such that s1s_1 divides s2s_2 and removes s2s_2 stones from some pile with at least s2s_2stones.

Then Bessie chooses some positive integer s3s_3 such that s2s_2 divides s3s_3 and removes s3s_3 stones from some pile with at least s3s_3

stones and so on.

In general, sis_i, the number of stones removed on turn ii, must divide s_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.


입력

The first line contains NN.

The second line contains NN space-separated integers a1,,aNa1,…,aN.


출력

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++).


예제1

입력
1
7
출력
4

Bessie wins if she removes 44, 55, 66, or 77

stones from the only pile. Then the game terminates immediately.


예제2

입력
6
3 2 3 2 3 1
출력
8

Bessie wins if she removes 22 or 33stones from any pile. Then the two players will alternate turns removing the same number of stones, with Bessie making the last move.


출처

USACO 2021 Febuary Gold


역링크 공식 문제집만

로그인해야 코드를 작성할 수 있어요.