You are given an array of positive integers which are some powers of . You have to do the following operations on the array-
Divide the array into groups. Each group should contain at least one element. And each element of the array should occur in exactly one group.
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: , we can divide it into two groups and . So, the summation of bitwise AND is , which is minimum possible and the summation of bitwise XOR is , which is maximum possible. So, the answer is .
Now write a program to calculate the answer.
The first line of the input contains a single integer the number of test cases.
Each test case consists of two lines. The first line of each test case contains an integer the number of the elements of the array . The next line contains integers. The integer is a positive integer , which is some power of two, .
Sum of over all test cases doesn’t exceed .
For each test case print a single integer in a single line which is the answer of the test case.
Input | Output |
---|---|
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 |