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 K = 17;
const int M = (1 << K);
int mod = 1e9 + 7;
int potmod(long long x, int m) {
  long long res = 1;
  while (m > 0) {
    if (m & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    m /= 2;
  }
  return res;
}
void transformxor(vector<long long> &P, int n, bool inverse) {
  for (int len = 1; 2 * len <= n; len <<= 1) {
    for (int i = 0; i < n; i += 2 * len) {
      for (int j = 0; j < len; j++) {
        long long u = P[i + j];
        long long v = P[i + len + j];
        P[i + j] = u + v;
        P[i + len + j] = u - v;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    P[i] %= mod;
    if (P[i] < 0) P[i] += mod;
  }
  if (inverse) {
    int odwr = potmod(n, mod - 2);
    for (int i = 0; i < n; i++) P[i] = (P[i] * odwr) % mod;
  }
}
void transformor(vector<long long> &P, int n, bool inverse) {
  for (int len = 1; 2 * len <= n; len <<= 1) {
    for (int i = 0; i < n; i += 2 * len) {
      for (int j = 0; j < len; j++) {
        long long u = P[i + j];
        long long v = P[i + len + j];
        if (!inverse) {
          P[i + j] = u + v;
          P[i + len + j] = u;
        } else {
          P[i + j] = v;
          P[i + len + j] = u - v;
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    P[i] %= mod;
    if (P[i] < 0) P[i] += mod;
  }
}
int ile[M + 7];
vector<long long> ixor(M);
long long sfib[M + 7];
long long ior[M + 7];
int ne[20];
void fun(int i, int msk, int mx) {
  if (i >= K) {
    ior[mx] += ((long long)ile[msk] * ile[mx ^ msk]);
    return;
  }
  fun(ne[i + 1], msk | (1 << i), mx);
  fun(ne[i + 1], msk, mx);
}
int fib[M + 7];
long long sfibi[M + 7];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    ile[x]++;
    sfib[x]++;
  }
  fib[0] = 0;
  fib[1] = 1;
  for (int i = 2; i <= M; ++i) fib[i] = (fib[i - 1] + fib[i - 2]) % mod;
  for (int x = 0; x < M; ++x) sfib[x] = (sfib[x] * fib[x]) % mod;
  for (int i = 0; i < K; ++i) {
    for (int x = 0; x < M; ++x) {
      if ((x & (1 << i)) == 0) {
        sfib[x ^ (1 << i)] += sfib[x];
        if (sfib[x ^ (1 << i)] >= mod) sfib[x ^ (1 << i)] -= mod;
      }
    }
  }
  for (int x = 0; x < M; ++x) {
    for (int i = 0; i < K; ++i) {
      if ((x & (1 << i)) == 0) {
        sfibi[x] += sfib[x | (1 << i)];
        sfibi[x] += mod - sfib[x];
      }
    }
    sfibi[x] %= mod;
  }
  for (int x = 0; x < M; ++x) {
    ne[K] = K;
    for (int j = K - 1; j >= 0; --j) {
      if (x & (1 << j))
        ne[j] = j;
      else
        ne[j] = ne[j + 1];
    }
    fun(ne[0], 0, x);
  }
  for (int x = 0; x < M; ++x) ior[x] %= mod;
  for (int i = 0; i < M; ++i) ixor[i] = ile[i];
  transformxor(ixor, M, 0);
  for (int i = 0; i < M; ++i) ixor[i] = (ixor[i] * ixor[i]) % mod;
  transformxor(ixor, M, 1);
  for (int x = 0; x < M; ++x) {
    ior[x] = (ior[x] * fib[x]) % mod;
    ixor[x] = (ixor[x] * fib[x]) % mod;
  }
  vector<long long> ior2(M);
  vector<long long> ixor2(M);
  for (int x = 0; x < M; ++x) ior2[x] = ior[(M - 1) ^ x];
  for (int x = 0; x < M; ++x) ixor2[x] = ixor[(M - 1) ^ x];
  transformor(ior2, M, 0);
  transformor(ixor2, M, 0);
  for (int x = 0; x < M; ++x) ior2[x] = (ior2[x] * ixor2[x]) % mod;
  transformor(ior2, M, 1);
  long long wynik = 0;
  for (int x = 0; x < M; ++x) {
    wynik += (ior2[x] * sfibi[x]) % mod;
  }
  wynik %= mod;
  cout << wynik << endl;
  return 0;
}