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 INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f3f3f3f3f3f3fll;
const long long M = 1e9 + 7;
const long long maxn = 1e6 + 7;
const double eps = 0.00000001;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template <typename T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <typename T>
inline T powMM(T a, T b) {
  T ret = 1;
  for (; b; b >>= 1ll, a = 1ll * a * a % M)
    if (b & 1) ret = 1ll * ret * a % M;
  return ret;
}
void fwt(long long *A, int len, int inv, int type) {
  int i, j, k;
  int div = powMM(2ll, M - 2);
  for (i = 2; i <= len; i <<= 1) {
    for (j = 0; j < len; j += i) {
      for (k = j; k < j + i / 2; k++) {
        if (inv == 1) {
          long long a = A[k], b = A[k + i / 2];
          if (type == 1) {
            A[k] = (a + b) % M;
            A[k + i / 2] = (a - b + M) % M;
          } else if (type == 2) {
            A[k] = (a + b) % M;
          } else if (type == 3) {
            A[k + i / 2] = (a + b) % M;
          }
        } else {
          long long a = A[k], b = A[k + i / 2];
          if (type == 1) {
            A[k] = (a + b) * div % M;
            A[k + i / 2] = (a - b + M) % M * div % M;
          } else if (type == 2) {
            A[k] = (a - b + M) % M;
          } else if (type == 3) {
            A[k + i / 2] = (b - a + M) % M;
          }
        }
      }
    }
  }
}
int k;
int n;
long long f[maxn];
long long A[maxn], B[maxn], C[maxn];
int g[maxn];
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &k), f[k]++;
  for (i = 0; i < (1 << 17); i++)
    for (j = i;; j = (j - 1) & i) {
      (A[i] += f[j] * f[i ^ j]) %= M;
      if (!j) break;
    }
  for (i = 0; i < (1 << 17); i++) B[i] = f[i];
  for (i = 0; i < (1 << 17); i++) C[i] = f[i];
  fwt(C, 1 << 17, 1, 1);
  for (i = 0; i < (1 << 17); i++) C[i] = (C[i] * C[i]) % M;
  fwt(C, 1 << 17, -1, 1);
  f[0] = 0;
  f[1] = 1;
  for (i = 2; i <= (1 << 17); i++) f[i] = (f[i - 1] + f[i - 2]) % M;
  for (i = 0; i < (1 << 17); i++) {
    (A[i] *= f[i]) %= M;
    (B[i] *= f[i]) %= M;
    (C[i] *= f[i]) %= M;
  }
  fwt(A, 1 << 17, 1, 2);
  fwt(B, 1 << 17, 1, 2);
  fwt(C, 1 << 17, 1, 2);
  for (i = 0; i < (1 << 17); i++) (A[i] *= B[i]) %= M, (A[i] *= C[i]) %= M;
  fwt(A, 1 << 17, -1, 2);
  int ANS = 0;
  for (i = 0; i < 17; i++) (ANS += A[1 << i]) %= M;
  printf("%d\n", ANS);
}