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[1000005], maxx, n, m, cnt[300000];
long long fib[300000], a[20][300000], b[20][300000], c[300000], d[300000],
    e[300000], f[20][300000], ans;
void fwt_xor(long long *a, int f) {
  for (int i = 1; i < m; i <<= 1)
    for (int j = 0; j < m; j += (i << 1))
      for (int k = 0; k < i; k++) {
        long long x = a[j + k], y = a[i + j + k];
        a[j + k] = (x + y) % 1000000007;
        a[i + j + k] = ((x - y) % 1000000007 + 1000000007) % 1000000007;
        if (f < 0)
          a[j + k] = a[j + k] * 500000004 % 1000000007,
                a[i + j + k] = a[i + j + k] * 500000004 % 1000000007;
      }
}
void fwt_or(long long *a, int f) {
  for (int i = 1; i < m; i <<= 1)
    for (int j = 0; j < m; j += (i << 1))
      for (int k = 0; k < i; k++) {
        long long x = a[j + k], y = a[i + j + k];
        if (f > 0) a[j + k] = x, a[i + j + k] = (x + y) % 1000000007;
        if (f < 0)
          a[j + k] = x,
                a[i + j + k] = ((y - x) % 1000000007 + 1000000007) % 1000000007;
      }
}
void fwt_and(long long *a, int f) {
  for (int i = 1; i < m; i <<= 1)
    for (int j = 0; j < m; j += (i << 1))
      for (int k = 0; k < i; k++) {
        long long x = a[j + k], y = a[i + j + k];
        if (f > 0) a[j + k] = (x + y) % 1000000007, a[i + j + k] = y;
        if (f < 0)
          a[j + k] = ((x - y) % 1000000007 + 1000000007) % 1000000007,
                a[i + j + k] = y;
      }
}
int main() {
  fib[1] = 1;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &s[i]), maxx = max(maxx, s[i]);
  for (m = 1; m <= maxx; m <<= 1)
    ;
  for (int i = 1; i < m; i++) cnt[i] = cnt[i >> 1] + (i & 1);
  for (int i = 2; i < m; i++) fib[i] = (fib[i - 1] + fib[i - 2]) % 1000000007;
  for (int 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 (int i = 0; i < m; i++) c[i] = c[i] * fib[i] % 1000000007;
  fwt_xor(d, 1);
  fwt_xor(e, 1);
  for (int i = 0; i < m; i++) d[i] = d[i] * e[i] % 1000000007;
  fwt_xor(d, -1);
  for (int i = 0; i < m; i++) d[i] = d[i] * fib[i] % 1000000007;
  for (int k = 0; k <= cnt[m - 1]; k++) fwt_or(a[k], 1), fwt_or(b[k], 1);
  for (int i = 0; i <= cnt[m - 1]; i++)
    for (int j = 0; j <= cnt[m - 1]; j++)
      for (int k = 0; k < m; k++)
        if (i + j <= cnt[m - 1])
          f[i + j][k] = (f[i + j][k] + a[i][k] * b[j][k]) % 1000000007;
  for (int i = 0; i <= cnt[m - 1]; i++) fwt_or(f[i], -1);
  for (int i = 0; i < m; i++) e[i] = f[cnt[i]][i] * fib[i] % 1000000007;
  fwt_and(c, 1);
  fwt_and(d, 1);
  fwt_and(e, 1);
  for (int i = 0; i < m; i++)
    c[i] = c[i] * d[i] % 1000000007 * e[i] % 1000000007;
  fwt_and(c, -1);
  for (int i = 1; i < m; i <<= 1) ans = (ans + c[i]) % 1000000007;
  printf("%I64d\n", ans);
  return 0;
}