LogiQuest

320. Sum of All Subset XORs

MediumBitsCombinatorics

Print the sum of the XOR of every subset (including the empty subset, whose XOR is 0).

Input format

Line 1: n Line 2: n integers

Output format

The sum.

Example 1

Input

2
1 3

Output

6

Example 2

Input

3
5 1 6

Output

28

Constraints

1 ≤ n ≤ 30 0 ≤ values ≤ 10⁶

Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.

Loading the MyLoginn IDE…