542. Gena vs Petya
Time limit per test: 1
second(s)
Memory limit: 262144
kilobytes
input: standard
output: standard
Gena and Petya love playing the following game with each other. There are
n piles of stones, the
ith pile contains
a_{i} stones. The players move in turns, Gena moves first. A player moves by choosing any nonempty pile and taking an arbitrary positive number of stones from it. If the move is impossible (that is, all piles are empty), then the game finishes and the current player is considered a loser.
Gena and Petya are the world famous experts in unusual games. We will assume that they play optimally.
Recently Petya started to notice that Gena wins too often. Petya decided that the problem is the unjust rules as Gena always gets to move first! To even their chances, Petya decided to cheat and take and hide some stones before the game begins. Since Petya does not want Gena to suspect anything, he will take the same number of stones
x from each pile. This number
x can be an arbitrary nonnegative integer, strictly less that the minimum of
a_{i} values.
Your task is to find the number of distinct numbers
x such that Petya will win the game.
Input
The first line contains the number of piles
n (1 ≤
n ≤ 2 · 10
^{5}). The second line contains
n spaceseparated integers
a_{i} (1 ≤
a_{i} ≤ 10
^{18}) — the piles' sizes.
Output
Print the number of ways to choose
x so that Petya will win the resulting game considering that both players play optimally.
Example(s)
sample input

sample output

2
3 3

3

sample input

sample output

3
3 4 5

1

sample input

sample output

4
2 7 4 1

1

sample input

sample output

4
4 6 8 10

2

Note
Consider the first example. Petya can choose any
x between 0 and 2. After it Gena starts the game with two piles of equal sizes and looses the game. In the second example there is a single possible value of
x, equal to 2. In the third example the sought
x is also only one — it's
x=0. In the fourth example there are two possible values of
x — they are 0 and 3.