P29665 [洛谷] [COCI2011-2012#1] X3
普及+
题目描述

Problem Description

Given a sequence of length $N$, $A_1, A_2, ..., A_N$, find the total sum of pairwise XORs of the sequence elements.

Input Format

The first line of input contains a positive integer $N$.

The next $N$ lines each contain a positive integer $A_i$.

Output Format

Output a single integer, which is the total sum of pairwise XORs.

Sample Input and Output

Sample Input #1

2
19
10

Sample Output #1

25

Sample Input #2

3
7
3
5

Sample Output #2

12

Sample Input #3

5
9
13
1
9
6

Sample Output #3

84

Notes

Sample 2 Explanation

$A_1 ⊕ A_2 = 4$, $A_1 ⊕ A_3 = 2$, $A_2 ⊕ A_3 = 6$, $4 + 2 + 6 = 12$, hence the answer is $12$.

Data Range

For $100\%$ of the data, $1 \le N \le 10^6$, $1 \le A_i \le 10^6$.

Notes

This problem's score is set according to the original COCI contest, with a maximum score of $110$.

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

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 19 10
样例输出
25