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>
#pragma GCC optimize(4)
using namespace std;
char _buf[100000], *_p1 = _buf, *_p2 = _buf;
inline int gi() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return (f == 1) ? x : -x;
}
inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a < b ? a : b; }
const int maxn = (1 << 17) + 5, mod = 1e9 + 7;
int n, cnt[maxn], fib[maxn];
int a[18][maxn], b[18][maxn], c[maxn];
int maxv;
inline int count(int x) {
  int ret = 0;
  while (x) ret += x & 1, x >>= 1;
  return ret;
}
inline int getlen(int x) {
  int bit = 0;
  while ((1 << bit) <= maxv) bit++;
  return bit;
}
inline void fwt_or(int *a, int n, int typ) {
  for (int l = 1; l < n; l <<= 1) {
    for (int i = 0; i < n; i += l << 1) {
      for (int j = 0; j < l; ++j) {
        if (typ == 1)
          a[i + j + l] = (a[i + j + l] + a[i + j]) % mod;
        else
          a[i + j + l] = (a[i + j + l] - a[i + j] + mod) % mod;
      }
    }
  }
}
inline void fwt_and(int *a, int n, int typ) {
  for (int l = 1; l < n; l <<= 1) {
    for (int i = 0; i < n; i += l << 1) {
      for (int j = 0; j < l; ++j) {
        if (typ == 1)
          a[i + j] = (a[i + j + l] + a[i + j]) % mod;
        else
          a[i + j] = (a[i + j] - a[i + j + l] + mod) % mod;
      }
    }
  }
}
inline void fwt_xor(int *a, int n, int typ) {
  for (int l = 1; l < n; l <<= 1) {
    for (int i = 0; i < n; i += l << 1) {
      for (int j = 0; j < l; ++j) {
        int x = a[i + j], y = a[i + j + l];
        if (typ == 1)
          a[i + j] = (x + y) % mod, a[i + j + l] = (x - y + mod) % mod;
        else
          a[i + j] = 1ll * (mod + 1) / 2 * (x + y) % mod,
                a[i + j + l] = 1ll * (mod + 1) / 2 * (x - y + mod) % mod;
      }
    }
  }
}
inline void init() {}
inline void input() {
  n = gi();
  for (int i = 1; i <= n; ++i) {
    int x = gi();
    cnt[x]++;
    maxv = max(maxv, x);
  }
  n = getlen(maxv);
}
int A[maxn], B[maxn], C[maxn];
inline void solve() {
  fib[0] = 0;
  fib[1] = 1;
  for (int i = 2; i <= (1 << n) - 1; ++i)
    fib[i] = fib[i - 1] + fib[i - 2], fib[i] %= mod;
  for (int i = 0; i <= (1 << n) - 1; ++i) a[count(i)][i] = cnt[i];
  for (int i = 0; i <= n; ++i) fwt_or(a[i], (1 << n), 1);
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= i; ++j)
      for (int k = 0; k <= (1 << n) - 1; ++k)
        b[i][k] = (b[i][k] + 1ll * a[j][k] * a[i - j][k]) % mod;
  for (int i = 0; i <= n; ++i) fwt_or(b[i], (1 << n), -1);
  for (int i = 0; i <= (1 << n) - 1; ++i)
    A[i] = 1ll * fib[i] * b[count(i)][i] % mod;
  for (int i = 0; i <= (1 << n) - 1; ++i) B[i] = 1ll * fib[i] * cnt[i] % mod;
  for (int i = 0; i <= (1 << n) - 1; ++i) c[i] = cnt[i];
  fwt_xor(c, (1 << n), 1);
  for (int i = 0; i <= (1 << n) - 1; ++i) c[i] = 1ll * c[i] * c[i] % mod;
  fwt_xor(c, (1 << n), -1);
  for (int i = 0; i <= (1 << n) - 1; ++i) C[i] = 1ll * fib[i] * c[i] % mod;
  fwt_and(A, (1 << n), 1);
  fwt_and(B, (1 << n), 1);
  fwt_and(C, (1 << n), 1);
  for (int i = 0; i <= (1 << n) - 1; ++i)
    A[i] = 1ll * A[i] * B[i] % mod * C[i] % mod;
  fwt_and(A, (1 << n), -1);
  int ans = 0;
  for (int i = 0; i <= n - 1; ++i) ans = (ans + A[1 << i]) % mod;
  printf("%d\n", ans);
}
int main() {
  int T = 1;
  while (T--) {
    init();
    input();
    solve();
  }
  return 0;
}