Fran recently learned the operation xor, which for two integers $x$ and $y$ returns the result by applying the bitwise exclusive or (exclusive $or$). The operation xor, denoted as ⊕, compares the corresponding bits of the numbers $x$ and $y$ and sets the result bit at each position according to the following rule:
- If the bits at the corresponding position are different (0 and 1, or 1 and 0), then the result bit is 1.
- If the bits are the same (0 and 0, or 1 and 1), then the result bit is 0. For example, for $x = 5$ and $y = 3$, the binary representations are: $x = 101_{2}$, $y = 011_{2}$. Applying xor to the corresponding bits gives $x$ ⊕$y = 101_{2}$ ⊕$011_{2}$ = $110_{2}$ = 6. In other words, 5 ⊕$3 = 6$. Fran received an array of $n$ integers $a_{1}$, $a_{2}$, . . . , $a_{n}$ and decided to do the following:
- For every pair of indices (i, j) where $1 \le i \le j \le n$, he calculated the sum $a_{i} + a_{j}$.
- Now he wants to calculate the result of the xor of all the obtained sums. Help Fran calculate the required result.
Input
In the first line of input, there is $n$ ($1 \le n \le 5 \cdot 10^{5}$), the length of the array. In the second line, there are $n$ numbers $a_{1}$, $a_{2}$, . . . , $a_{n}$ ($0 \le a_{i} < 2^{30}$) as described in the problem statement.
Output
In the only line of output, print the required result.
Example 1
3 2 4 5
14
Example 2
4 6 7 3 1
3
Example 3
7 2 3 5 7 9 11 13
6
Clarification of the first example: The sums are 2 + 2 = 4, 2 + 4 = 6, 2 + 5 = 7, 4 + 4 = 8, 4 + 5 = 9, and 5 + 5 = 10. The result is 4 ⊕6 ⊕7 ⊕8 ⊕9 ⊕10 = 14.
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.