#P7627. [COCI 2011/2012 #1] X3

[COCI 2011/2012 #1] X3

Description

Given a sequence A1,A2,...,ANA_1, A_2, ..., A_N of length NN, find the sum of the pairwise XOR of all elements in the sequence.

Input Format

The first line contains a positive integer NN.

The next NN lines each contain a positive integer AiA_i.

Output Format

Output one integer on a single line, representing the sum after taking XOR over all unordered pairs.

2
19
10
25
3
7
3
5
12
5
9
13
1
9
6
84

Hint

Sample 2 Explanation

A1A2=4A_1 ⊕ A_2 = 4, A1A3=2A_1 ⊕ A_3 = 2, A2A3=6A_2 ⊕ A_3 = 6, and 4+2+6=124 + 2 + 6 = 12, so the answer is 1212.

Constraints

For 100%100\% of the testdata, 1N1061 \le N \le 10^6 and 1Ai1061 \le A_i \le 10^6.

Notes

The score of this problem follows the original COCI setting, with a full score of 110110.

This problem is translated from COCI2011-2012 CONTEST #1 T3 X3.

Translated by ChatGPT 5