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;
const long long mod = 1e9 + 7, inv2 = 5e8 + 4;
long long n, ansa = 0, ans[(1 << 17) + 10], dp[(1 << 17) + 10], a[1000005],
             cnt[(1 << 17) + 10], b[18][(1 << 17) + 10], f[18][(1 << 17) + 10];
long long res[(1 << 17) + 10], res1[(1 << 17) + 10], res2[(1 << 17) + 10],
    tmp[(1 << 17) + 10], tmp1[(1 << 17) + 10];
long long read() {
  long long f = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    f = f * 10 + ch - '0';
    ch = getchar();
  }
  return f * w;
}
long long count(long long x) {
  long long sum = 0;
  while (x) sum++, x -= (x & -x);
  return sum;
}
void fwt_or(long long *c, long long len, long long type) {
  for (long long l = 2; l <= len; l <<= 1) {
    for (long long j = 0; j < len; j += l) {
      for (long long k = j; k < j + l / 2; k++) {
        long long x = c[k], y = c[k + l / 2];
        c[k + l / 2] = (y + type * x + mod) % mod;
      }
    }
  }
}
void fwt_and(long long *c, long long len, long long type) {
  for (long long l = 2; l <= len; l <<= 1) {
    for (long long j = 0; j < len; j += l) {
      for (long long k = j; k < j + l / 2; k++) {
        long long x = c[k], y = c[k + l / 2];
        c[k] = (x + type * y + mod) % mod;
      }
    }
  }
}
void fwt_xor(long long *c, long long len, long long type) {
  for (long long l = 2; l <= len; l <<= 1) {
    for (long long j = 0; j < len; j += l) {
      for (long long k = j; k < j + l / 2; k++) {
        long long x = c[k], y = c[k + l / 2];
        if (type == 1)
          c[k] = (x + y) % mod, c[k + l / 2] = (x - y + mod) % mod;
        else
          c[k] = (x + y) * inv2 % mod,
          c[k + l / 2] = (x - y + mod) * inv2 % mod;
      }
    }
  }
}
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) a[i] = read(), cnt[a[i]]++;
  dp[1] = 1;
  for (long long i = 2; i < (1 << 17); i++)
    dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
  memset(tmp, 0, sizeof(tmp));
  for (long long i = 0; i < (1 << 17); i++) tmp[i] = cnt[i];
  fwt_xor(tmp, 1 << 17, 1);
  for (long long i = 0; i < (1 << 17); i++) tmp[i] = tmp[i] * tmp[i] % mod;
  fwt_xor(tmp, 1 << 17, -1);
  memcpy(res, tmp, sizeof(res));
  for (long long i = 0; i < (1 << 17); i++) res[i] = res[i] * dp[i] % mod;
  memcpy(res1, cnt, sizeof(res1));
  for (long long i = 0; i < (1 << 17); i++) res1[i] = res1[i] * dp[i] % mod;
  for (long long i = 0; i < (1 << 17); i++) b[count(i)][i] = cnt[i];
  for (long long i = 0; i <= 17; i++) fwt_or(b[i], 1 << 17, 1);
  for (long long i = 0; i <= 17; i++) {
    for (long long j = 0; j <= i; j++) {
      for (long long k = 0; k < (1 << 17); k++) {
        f[i][k] = (f[i][k] + b[j][k] * b[i - j][k] % mod) % mod;
      }
    }
    fwt_or(f[i], 1 << 17, -1);
  }
  for (long long i = 0; i < (1 << 17); i++)
    res2[i] = f[count(i)][i] * dp[i] % mod;
  fwt_and(res, 1 << 17, 1), fwt_and(res1, 1 << 17, 1),
      fwt_and(res2, 1 << 17, 1);
  for (long long i = 0; i < (1 << 17); i++)
    ans[i] = res[i] * res1[i] % mod * res2[i] % mod;
  fwt_and(ans, 1 << 17, -1);
  for (long long i = 1; i < (1 << 17); i <<= 1) ansa = (ansa + ans[i]) % mod;
  printf("%lld\n", ansa);
  return 0;
}