E. Boneca Ambalabu
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Boneca Ambalabu gives you a sequence of $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$.

Output the maximum value of $$$(a_k\oplus a_1)+(a_k\oplus a_2)+\ldots+(a_k\oplus a_n)$$$ among all $$$1 \leq k \leq n$$$. Note that $$$\oplus$$$ denotes the bitwise XOR operation.

Input

The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) – the number of independent test cases.

The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n\leq 2\cdot 10^5$$$) – the length of the array.

The second line of each test case contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$0 \leq a_i \lt 2^{30}$$$).

It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot 10^5$$$.

Output

For each test case, output the maximum value on a new line.

Example
Input
5
3
18 18 18
5
1 2 4 8 16
5
8 13 4 5 15
6
625 676 729 784 841 900
1
1
Output
0
79
37
1555
0
Note

In the first test case, the best we can do is $$$(18\oplus18)+(18\oplus18)+(18\oplus18)=0$$$.

In the second test case, we choose $$$k=5$$$ to get $$$(16\oplus1)+(16\oplus2)+(16\oplus4)+(16\oplus8)+(16\oplus16)=79$$$.