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>
const int mod = 1000000007, N = 1 << 17;
int mul(int a, int b) { return a * (long long)b % mod; }
int ad(int a, int b) { return (a + b) % mod; }
int de(int a, int b) { return (a - b) % mod; }
int pow(int a, int b) {
  int s = 1;
  while (b) {
    if (b & 1) s = mul(s, a);
    a = mul(a, a);
    b >>= 1;
  }
  return s;
}
void fwt_xor(int* a, int on) {
  int i, j, k, t;
  for (i = 2; i <= N; i <<= 1) {
    for (j = 0; j < N; j += i) {
      for (k = 0; k < i >> 1; k++) {
        t = a[i / 2 + j + k];
        a[i / 2 + j + k] = de(a[j + k], t);
        a[j + k] = ad(a[j + k], t);
      }
    }
  }
  if (on == -1) {
    t = pow(N, mod - 2);
    for (i = 0; i < N; i++) a[i] = mul(a[i], t);
  }
}
void fwt_or(int* a, int on) {
  int i, j, k;
  for (i = 2; i <= N; i <<= 1) {
    for (j = 0; j < N; j += i) {
      for (k = 0; k < i >> 1; k++)
        a[i / 2 + j + k] = ad(a[i / 2 + j + k], on * a[j + k]);
    }
  }
}
void fwt_and(int* a, int on) {
  int i, j, k;
  for (i = 2; i <= N; i <<= 1) {
    for (j = 0; j < N; j += i) {
      for (k = 0; k < i >> 1; k++)
        a[j + k] = ad(a[j + k], on * a[i / 2 + j + k]);
    }
  }
}
int f[18][N], g[18][N], cnt[N];
void conv(int* a) {
  int i, j, k;
  memset(f, 0, sizeof(f));
  memset(g, 0, sizeof(g));
  for (i = 0; i < N; i++) f[cnt[i]][i] = a[i];
  for (i = 0; i < 18; i++) fwt_or(f[i], 1);
  for (i = 0; i < 18; i++) {
    for (j = 0; j <= i; j++) {
      for (k = 0; k < N; k++) g[i][k] = ad(g[i][k], mul(f[j][k], f[i - j][k]));
    }
  }
  for (i = 0; i < 18; i++) fwt_or(g[i], -1);
  for (i = 0; i < N; i++) a[i] = g[cnt[i]][i];
}
int fib[N], A[N], B[N], C[N], D[N];
int main() {
  int n, i, s;
  fib[1] = 1;
  for (i = 2; i < N; i++) fib[i] = ad(fib[i - 1], fib[i - 2]);
  for (i = 1; i < N; i++) cnt[i] = cnt[i >> 1] + (i & 1);
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &i);
    A[i]++;
  }
  for (i = 0; i < N; i++) D[i] = C[i] = B[i] = A[i];
  conv(B);
  fwt_xor(D, 1);
  for (i = 0; i < N; i++) D[i] = mul(D[i], D[i]);
  fwt_xor(D, -1);
  for (i = 0; i < N; i++) {
    B[i] = mul(B[i], fib[i]);
    C[i] = mul(C[i], fib[i]);
    D[i] = mul(D[i], fib[i]);
  }
  fwt_and(B, 1);
  fwt_and(C, 1);
  fwt_and(D, 1);
  for (i = 0; i < N; i++) A[i] = mul(mul(B[i], C[i]), D[i]);
  fwt_and(A, -1);
  s = 0;
  for (i = 1; i < N; i <<= 1) s = ad(s, A[i]);
  printf("%d", ad(s, mod));
}