#aaa002. 区间异或和

区间异或和

【题目描述】

给出 nn 个整数 a1,a2,…,ana_1,a_2,\ldots,a_n,请求出 $\displaystyle\sum_{i=1}^{n-1}\sum_{j=i+1}^{n}(a_i\operatorname{xor}a_j)$ 对 109+710^9+7 取模的值。其中 xor⁡\operatorname{xor} 表示按位异或。

【输入格式】

输入按以下格式从标准输入给出:

nn

a1a_1   a2a_2   ⋯\cdots   ana_n

【输出格式】

输出 $\displaystyle\sum_{i=1}^{n-1}\sum_{j=i+1}^{n}(a_i\operatorname{xor}a_j)$ 对 109+710^9+7 取模的值。

【样例】

3
1 2 3
6
10
3 1 4 1 5 9 2 6 5 3
237
10
3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820
103715602

【样例解释】

样例 1 中,三个数对的异或值分别为 33、22 和 11,相加得到 66。

【数据范围】

  • 2≤n≤3×1052\le n\le 3\times 10^5。
  • 0≤ai≤2600\le a_i\le 2^{60}。