Problem: 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
  * (sa | sb) & sc & (sd ^ se) = 2i for some integer i
  * sa & sb = 0



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

Find the sum of f(sa|sb) * f(sc) * f(sd^se) 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 109 + 7.

Input

The first line of input contains an integer n (1 ≤ n ≤ 106).

The second line of input contains n integers si (0 ≤ si < 217).

Output

Output the sum as described above, modulo 109 + 7

Examples

Input

2
1 2


Output

32


Input

3
7 4 1


Output

3520


Input

10
1 3 0 7 3 7 6 5 7 5


Output

1235424


Input

10
50 9 11 44 39 40 5 39 23 7


Output

113860062

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int s[1000010], cnt[131100];
long long fib[131100], a[18][131100], b[18][131100], c[131100], d[131100],
    e[131100], f[18][131100];
int main() {
  int n, m = 1, mx = 0, k, i, j;
  long long t, ans = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &s[i]), mx = max(mx, s[i]);
  while (m <= mx) m <<= 1;
  fib[1] = 1;
  for (i = 2; i < m; i++) fib[i] = (fib[i - 1] + fib[i - 2]) % 1000000007;
  for (i = 1; i < m; i++) cnt[i] = cnt[i - (i & -i)] + 1;
  for (i = 1; i <= n; i++)
    a[cnt[s[i]]][s[i]]++, b[cnt[s[i]]][s[i]]++, c[s[i]]++, d[s[i]]++, e[s[i]]++;
  for (i = 0; i < m; i++) c[i] = c[i] * fib[i] % 1000000007;
  for (i = 1; i < m; i <<= 1)
    for (j = 0; j < m; j++)
      if (i & j)
        t = d[j], d[j] = (d[j - i] - t + 1000000007) % 1000000007,
        d[j - i] = (d[j - i] + t) % 1000000007;
  for (i = 1; i < m; i <<= 1)
    for (j = 0; j < m; j++)
      if (i & j)
        t = e[j], e[j] = (e[j - i] - t + 1000000007) % 1000000007,
        e[j - i] = (e[j - i] + t) % 1000000007;
  for (i = 0; i < m; i++) d[i] = d[i] * e[i] % 1000000007;
  for (i = 1; i < m; i <<= 1)
    for (j = 0; j < m; j++)
      if (i & j)
        t = d[j], d[j] = (d[j - i] - t + 1000000007) * 500000004 % 1000000007,
        d[j - i] = (d[j - i] + t) * 500000004 % 1000000007;
  for (i = 0; i < m; i++) d[i] = d[i] * fib[i] % 1000000007;
  for (k = 0; k <= cnt[m - 1]; k++) {
    for (i = 1; i < m; i <<= 1)
      for (j = 0; j < m; j++)
        if (i & j) a[k][j] = (a[k][j] + a[k][j - i]) % 1000000007;
    for (i = 1; i < m; i <<= 1)
      for (j = 0; j < m; j++)
        if (i & j) b[k][j] = (b[k][j] + b[k][j - i]) % 1000000007;
  }
  for (i = 0; i <= cnt[m - 1]; i++)
    for (j = 0; j <= cnt[m - 1] - i; j++)
      for (k = 0; k < m; k++)
        f[i + j][k] = (f[i + j][k] + a[i][k] * b[j][k]) % 1000000007;
  for (k = 0; k <= cnt[m - 1]; k++)
    for (i = 1; i < m; i <<= 1)
      for (j = 0; j < m; j++)
        if (i & j) f[k][j] = (f[k][j] - f[k][j - i] + 1000000007) % 1000000007;
  for (i = 0; i < m; i++) e[i] = f[cnt[i]][i] * fib[i] % 1000000007;
  for (i = 1; i < m; i <<= 1)
    for (j = 0; j < m; j++)
      if (i & j) c[j - i] = (c[j - i] + c[j]) % 1000000007;
  for (i = 1; i < m; i <<= 1)
    for (j = 0; j < m; j++)
      if (i & j) d[j - i] = (d[j - i] + d[j]) % 1000000007;
  for (i = 1; i < m; i <<= 1)
    for (j = 0; j < m; j++)
      if (i & j) e[j - i] = (e[j - i] + e[j]) % 1000000007;
  for (i = 0; i < m; i++) c[i] = c[i] * d[i] % 1000000007 * e[i] % 1000000007;
  for (i = 1; i < m; i <<= 1)
    for (j = 0; j < m; j++)
      if (i & j) c[j - i] = (c[j - i] - c[j] + 1000000007) % 1000000007;
  for (i = 1; i < m; i <<= 1) ans = (ans + c[i]) % 1000000007;
  cout << ans << endl;
  return 0;
}