# XOR-AND Coupling

Criterion 2022 Round 17
Limits 1s, 512 MB

You are given an array $A$ of $N$ positive integers $A_1, A_2, ………..,A_{N-1}, A_N$ which are some powers of $2$. You have to do the following operations on the array-

1. Divide the array into $K$$( 1 \le K \le N )$ groups. Each group should contain at least one element. And each element of the array should occur in exactly one group.

2. The summation of bitwise AND of the elements of each group is minimum.

Find the maximum possible summation of bitwise XOR of the elements of each group so that all the above conditions are satisfied.

For example, given an array: $[4,8,16,2,2]$, we can divide it into two groups $[ 2, 4 ]$and $[ 2, 8, 16 ]$. So, the summation of bitwise AND is $(2$ $\&$ $4)$ $+$ $(2$ $\&$ $8$ $\&$ $16)$ $= 0 + 0 = 0$, which is minimum possible and the summation of bitwise XOR is $(2 \oplus 4) + (2 \oplus 8 \oplus 16) = 6 + 26 = 32$, which is maximum possible. So, the answer is $32$.

Now write a program to calculate the answer.

## Input

The first line of the input contains a single integer $T$$( 1\le T \le 5\times 10^5 )-$the number of test cases.

Each test case consists of two lines. The first line of each test case contains an integer $N$$( 1 \le N \le 5 \times 10^5 )-$the number of the elements of the array $A$. The next line contains $N$ integers. The $i^{th}$$( 1 \le i \le N )$ integer is a positive integer $A_i$, which is some power of two, $2^k$$( 0 \le k \le 30 )$.

Sum of $N$ over all test cases doesn’t exceed $5\times10^5$.

## Output

For each test case print a single integer in a single line which is the answer of the test case.

## Sample

InputOutput
3
5
4 8 16 2 2
6
4 8 4 32 16 8
7
2 2 2 2 4 16 64

32
72
88