Xor

시간 제한1초메모리 제한2048 MB

요약
i <= j인 모든 쌍의 합 a_i + a_j를 전부 xor한 값을 구한다.
난이도

어려움10점 중 8점

유형
비트 연산, 정렬, 이분 탐색
정답자
아직 제출이 없습니다

문제

Fran recently learned the operation xor, which for two integers xx and yy returns the result by applying the bitwise exclusive or (exclusive or). The operation xor, denoted as ⊕\oplus, compares the corresponding bits of the numbers xx and yy and sets the result bit at each position according to the following rule:

  • If the bits at the corresponding position are different (00 and 11, or 11 and 00), then the result bit is 11.
  • If the bits are the same (00 and 00, or 11 and 11), then the result bit is 00.

For example, for x=5x = 5 and y=3y = 3, the binary representations are: x=101_2x = 101\_2, y=011_2y = 011\_2. Applying xor to the corresponding bits gives x⊕y=101_2⊕011_2=110_2=6x \oplus y = 101\_2 \oplus 011\_2 = 110\_2 = 6. In other words, 5⊕3=65 \oplus 3 = 6.

Fran received an array of nn integers a_1,a_2,…,a_na\_1, a\_2, \dots , a\_n and decided to do the following:

  1. For every pair of indices (i,j)(i, j) where 1≤i≤j≤n1 ≤ i ≤ j ≤ n, he calculated the sum a_i+a_ja\_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 nn (1≤n≤5⋅1051 ≤ n ≤ 5 \cdot 10^5), the length of the array.

In the second line, there are nn numbers a_1,a_2,…,a_na\_1, a\_2, \dots , a\_n (0≤a_i<2300 ≤ a\_i < 2^{30}) as described in the problem statement.

출력

In the only line of output, print the required result.

힌트

Clarification of the first example:

The sums are 2+2=42 + 2 = 4, 2+4=62 + 4 = 6, 2+5=72 + 5 = 7, 4+4=84 + 4 = 8, 4+5=94 + 5 = 9, and 5+5=105 + 5 = 10. The result is 4⊕6⊕7⊕8⊕9⊕10=144 \oplus 6 \oplus 7 \oplus 8 \oplus 9 \oplus 10 = 14.

예제3

  1. 예제 1

    입력
    3
    2 4 5
    
    예상 출력
    14
    
  2. 예제 2

    입력
    4
    6 7 3 1
    
    예상 출력
    3
    
  3. 예제 3

    입력
    7
    2 3 5 7 9 11 13
    
    예상 출력
    6