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:
1. For every pair of indices (i, j) where \(1 \le i \le j \le n\), he calculated the sum \(a_{i} + a_{j}\).
2. Now he wants to calculate the result of the xor of all the obtained sums.
Help Fran calculate the required result.
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.
In the only line of output, print the required result.
| 서브태스크 | 점수 | 설명 |
|---|---|---|
1 | 7점 | \(n \le 2000\) |
2 | 17점 | \(a_{i} < 2^{10}\) for every \(i\) |
3 | 45점 | \(n \le 10^{5}\) |
4 | 21점 | No additional constraints. |
3
2 4 5144
6 7 3 137
2 3 5 7 9 11 136Clarification 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.