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 int maxn = 150010, mod = 1e9 + 7, inv2 = 500000004;
template <typename Tp>
int getmin(Tp &x, Tp y) {
  return y < x ? x = y, 1 : 0;
}
template <typename Tp>
int getmax(Tp &x, Tp y) {
  return y > x ? x = y, 1 : 0;
}
template <typename Tp>
void read(Tp &x) {
  x = 0;
  char ch = getchar();
  int f = 0;
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') ch = getchar(), f = 1;
  while (ch >= '0' && ch <= '9') x = x * 10 + (ch - '0'), ch = getchar();
  if (f) x = -x;
}
int n, N, l, ans, f[maxn], cnt[maxn], a[maxn], b[maxn], c[maxn], t1[maxn];
int t2[18][maxn], t3[18][maxn];
int pls(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }
int dec(int x, int y) { return x - y < 0 ? x - y + mod : x - y; }
void fwt_or(int *a, int f) {
  for (int i = 1; i < N; i <<= 1)
    for (int j = 0; j < N; j += (i << 1))
      for (int k = 0; k < i; ++k)
        a[j + k + i] = (f == 1 ? pls(a[j + k + i], a[j + k])
                               : dec(a[j + k + i], a[j + k]));
}
void fwt_and(int *a, int f) {
  for (int i = 1; i < N; i <<= 1)
    for (int j = 0; j < N; j += (i << 1))
      for (int k = 0; k < i; ++k)
        a[j + k] = (f == 1 ? pls(a[j + k], a[j + k + i])
                           : dec(a[j + k], a[j + k + i]));
}
void fwt_xor(int *a, int f) {
  for (int i = 1; i < N; i <<= 1)
    for (int j = 0; j < N; j += (i << 1))
      for (int k = 0; k < i; ++k) {
        int x = a[j + k], y = a[j + k + i];
        a[j + k] = pls(x, y);
        a[j + k + i] = dec(x, y);
        if (f == -1)
          a[j + k] = (long long)a[j + k] * inv2 % mod,
                a[j + k + i] = (long long)a[j + k + i] * inv2 % mod;
      }
}
void input() {
  int x, mx = 0;
  read(n);
  f[1] = 1;
  cnt[1] = 1;
  for (int i = 1; i <= n; i++) {
    read(x);
    ++b[x];
    getmax(mx, x);
  }
  for (N = 1; N <= mx; N <<= 1) ++l;
  for (int i = 2; i < N; i++)
    f[i] = pls(f[i - 1], f[i - 2]), cnt[i] = cnt[i >> 1] + (i & 1);
}
int main() {
  input();
  memmove(t1, b, sizeof(b));
  fwt_xor(t1, 1);
  for (int i = 0; i < N; i++) c[i] = (long long)t1[i] * t1[i] % mod;
  fwt_xor(c, -1);
  for (int i = 0; i < N; i++) t3[cnt[i]][i] = b[i];
  for (int i = 0; i <= l; i++) fwt_or(t3[i], 1);
  for (int i = 0; i <= l; i++)
    for (int j = 0; i + j <= l; j++)
      for (int r = 0; r < N; r++)
        t2[i + j][r] = pls(t2[i + j][r], (long long)t3[i][r] * t3[j][r] % mod);
  for (int i = 0; i <= l; i++) fwt_or(t2[i], -1);
  for (int i = 0; i < N; i++) a[i] = t2[cnt[i]][i];
  for (int i = 0; i < N; i++) {
    a[i] = (long long)a[i] * f[i] % mod;
    b[i] = (long long)b[i] * f[i] % mod;
    c[i] = (long long)c[i] * f[i] % mod;
  }
  fwt_and(a, 1);
  fwt_and(b, 1);
  fwt_and(c, 1);
  for (int i = 0; i < N; i++) a[i] = (long long)a[i] * b[i] % mod * c[i] % mod;
  fwt_and(a, -1);
  for (int i = 1; i < N; i <<= 1) ans = pls(ans, a[i]);
  printf("%d\n", ans);
  return 0;
}