Codecraft-18 and Codeforces Round 458 (Div. 1 + Div. 2, combined)
G
Sum the Fibonacci
Codeforces
2600
原题
← FH →
翻译中…

You are given an array $*s*$ of $*n*$ non-negative integers.

翻译中…

A 5-tuple of integers $(*a*, *b*, *c*, *d*, *e*)$ is said to be valid if it satisfies the following conditions:

翻译中…
  • $1 ≤ *a*, *b*, *c*, *d*, *e* ≤ *n*$
  • $(*s*_{*a*}$ | $*s*_{*b*})$ & $*s*_{*c*}$ & $(*s*_{*d*}$ ^ $*s*_{*e*}) = 2^{*i*}$ for some integer $*i*$
  • $*s*_{*a*}$ & $*s*_{*b*} = 0$
翻译中…

Here, '|' is the bitwise OR, '&' is the bitwise AND and '^' is the bitwise XOR operation.

翻译中…

Find the sum of $*f*(*s*_{*a*}$|$*s*_{*b*}) * *f*(*s*_{*c*}) * *f*(*s*_{*d*}$^$*s*_{*e*})$ over all valid 5-tuples $(*a*, *b*, *c*, *d*, *e*)$, where $*f*(*i*)$ is the $*i*$-th Fibonnaci number ($*f*(0) = 0, *f*(1) = 1, *f*(*i*) = *f*(*i* - 1) + *f*(*i* - 2)$).

翻译中…

Since answer can be is huge output it modulo $10^{9} + 7$.

翻译中…

Input

翻译中…

The first line of input contains an integer $*n*$ ($1 ≤ *n* ≤ 10^{6}$).

翻译中…

The second line of input contains $*n*$ integers $*s*_{*i*}$ ($0 ≤ *s*_{*i*} < 2^{17}$).

翻译中…

Output

翻译中…

Output the sum as described above, modulo $10^{9} + 7$

翻译中…

样例

Input #1
2
1 2
Output #1
32
InputCopy OutputCopy
Input #2
3
7 4 1
Output #2
3520
InputCopy OutputCopy
Input #3
10
1 3 0 7 3 7 6 5 7 5
Output #3
1235424
InputCopy OutputCopy
Input #4
10
50 9 11 44 39 40 5 39 23 7
Output #4
113860062
InputCopy OutputCopy
题目信息
题号
914G
时间限制
4 s
内存限制
256 MB
标签
位运算
分治
动态规划
FFT
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。