 Timer is Running

Sum of XOR of all pairs
##### Submissions: 4036   Accuracy: 18.75%   Difficulty: Medium   Marks: 4

Given an array of N integers, find the sum of xor of all pairs of numbers in the array.

Input:
The first line of the input contains a single integer T denoting the number of test cases. The first line of each test case contains
N. followed by n separate integers.

Output:
For each test case, output a single integer i.e sum of xor of all pairs of numbers in the array.

Constraints
1 ≤ T ≤ 1000
2 ≤ N ≤ 10^5
1 ≤ A[i] ≤ 10^5

Example:
Input :
2
3
7 3 5
4
5 9 7 6
Output :
12
47

Explanation :

Testcase 1: all possible pairs and there Xor Value : ( 3 ^ 5 = 6 ) + (7 ^ 3 = 4) + ( 7 ^ 5 = 2 ) : 6 + 4 + 2 = 12

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Nishant Singh
Author: Nishant_Singh

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.