# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

## Total Hamming Distance

The * Hamming distance* between two integers is the number of positions at which the corresponding bits are different.
Now your job is to find the total Hamming distance between all pairs of the given numbers. For example, if the input array is

**[4, 14, 2]**, the output will be 6.

**Explanation:** In binary representation, the 4 is 0100, 14 is 1110, and 2 is 0010 (just showing the four bits relevant in this case). So the answer will be:

**HammingDistance(4, 14) + HammingDistance(4, 2) + HammingDistance(14, 2) = 2 + 2 + 2 = 6.**

#### Input

Input starts with an integer **T**, denoting the number of test cases (**0 < T ≤ 10**). Each test case consists of two lines. The first line contains a positive integer **N**, the size of the array (**0 < N ≤ 10 ^{5}**). The next line contains the N space separated integers

**a**(

_{1}, a_{2}, … , a_{N}**0 ≤ a**).

_{i}≤ 10^{12}#### Output

For each test case, print the total hamming distance of the given numbers.

#### Samples

Input | Output |
---|---|

1 3 4 14 | 6 |

Login to submit