Sum of Pairwise XORs
You are given an array of n non-negative integers a_1, a_2, ..., a_n.
Compute the sum of a_i XOR a_j over all pairs of indices 1 ≤ i < j ≤ n, where XOR is the
bitwise exclusive or. Each unordered pair of positions is counted exactly once, even if the two
values are equal.
The sum can be very large, so print it modulo 10^9 + 7.
Input
The first line contains a single integer n (1 ≤ n ≤ 3·10^5).
The second line contains n integers a_1, a_2, ..., a_n (0 ≤ a_i < 2^30).
Output
Print a single integer: the sum of a_i XOR a_j over all pairs i < j, taken modulo 10^9 + 7.
Notes
In the first example the pairs give 1 XOR 2 = 3, 1 XOR 3 = 2 and 2 XOR 3 = 1, for a total of 6.
In the second example the six pairs give 7 + 4 + 9 + 3 + 14 + 13 = 50.
If n = 1 there are no pairs and the answer is 0.