Present | 프로그래밍의 벗 PivotOJ
PivotOJ

Present

시간 제한: 3000ms메모리 제한: 1024MB출처: MOOI 2019-20 finalBOJ 30697

문제

Catherine received an array of integers as a gift for March 8. Eventually she grew bored with it, and she started calculated various useless characteristics for it. She succeeded to do it for each one she came up with. But when she came up with another one --- xor of all pairwise sums of elements in the array, she realized that she couldn't compute it for a very large array, thus she asked for your help. Can you do it? Formally, you need to compute

(a1+a2)(a1+a3)(a1+an)(a2+a3)(a2+an)(an1+an)\begin{align*} (a_1 + a_2) \oplus (a_1 + a_3) \oplus \ldots \oplus (a_1 + a_n) \oplus \\ \oplus (a_2 + a_3) \oplus \ldots \oplus (a_2 + a_n) \oplus \\ \ldots \\ \oplus (a_{n-1} + a_n) \\ \end{align*}

입력

The first line contains a single integer nn (2n4000002 \leq n \leq 400\,000) --- the number of integers in the array.

The second line contains integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai1071 \leq a_i \leq 10^7).

출력

Print a single integer --- xor of all pairwise sums of integers in the given array.

힌트

In the first sample case there is only one sum 1+2=31 + 2 = 3.

In the second sample case there are three sums: 1+2=31 + 2 = 3, 1+3=41 + 3 = 4, 2+3=52 + 3 = 5. In binary they are represented as 011210021012=0102011_2 \oplus 100_2 \oplus 101_2 = 010_2, thus the answer is 2.

\oplus is the bitwise xor operation. To define xyx \oplus y, consider binary representations of integers xx and yy. We put the ii-th bit of the result to be 1 when exactly one of the ii-th bits of xx and yy is 1. Otherwise, the ii-th bit of the result is put to be 0. For example, 0101200112=011020101_2 \, \oplus \, 0011_2 = 0110_2.

예제

예제 1

입력
2
1 2
출력
3

예제 2

입력
3
1 2 3
출력
2
코드를 제출하려면 로그인하세요.