Type: Default 2000ms 256MiB

异或计算

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Problem Description

给定nn长非负整数数组aa,要求计算:

$$E = \sum_{i_1 = 1}^{n} \sum_{i_2 = 1}^{n} ...\sum_{i_n = 1}^{n} (a_{i_1} \oplus a_{i_2} \oplus .... \oplus a_{i_n} )$$

例如:

当n=2n = 2时,$E = \sum_{i_1 = 1}^{2} \sum_{i_2 = 1}^{2} (a_{i_1} \oplus a_{i_2}) = a_1 \oplus a_1 + a_1 \oplus a_2 + a_2 \oplus a_1 + a_2 \oplus a_2$.

Input Format

第一行输入一个正整数n(1≤n≤106)n (1 \le n \le 10^6)

第二行输入nn个非负整数,依次代表 a1,a2,...,an(1≤ai≤109)a_1,a_2,...,a_n (1 \le a_i \le 10^9)。

Output Format

输出EE 对 PP 取模的结果,即EE % P,P, 其中 P=1000000007P = 1000000007.

Sample

输入 # 1

3
3 1 3

输出 # 1

55