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 L = 17;
const int N = 1 << 17;
const int rN = 742744451;
const int md = 1e9 + 7;
int A[L + 1][N], B[L + 1][N];
int ab[N], c[N], de[N], f[N], pc[N];
void amod(int &x) {
  while (x >= md) x -= md;
  while (x < 0) x += md;
}
void sos(int a[], int b[]) {
  for (int i = 0; i < L; ++i) {
    for (int m = 0; m < N; ++m) {
      if (m >> i & 1) continue;
      amod(a[m] += a[m ^ 1 << i]);
      amod(b[m] += b[m ^ 1 << i]);
    }
  }
}
void isos(int a[]) {
  for (int i = 0; i < L; ++i) {
    for (int m = 0; m < N; ++m) {
      if (m >> i & 1) continue;
      amod(a[m] -= a[m ^ 1 << i]);
    }
  }
}
int main() {
  f[1] = 1;
  pc[1] = 1;
  for (int i = 2; i < N; ++i) {
    amod(f[i] = f[i - 1] + f[i - 2]);
    pc[i] = pc[i & (i - 1)] + 1;
  }
  int n, x, y;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    ++c[x];
  }
  for (int i = 0; i < N; ++i) {
    A[pc[i]][i] = c[i];
    B[pc[i]][i] = c[i];
  }
  for (int j = 0; j <= L; ++j) sos(A[j], B[j]);
  for (int m = 0; m < N; ++m) {
    for (int k = L; k >= 0; --k) {
      x = 0;
      for (int j = 0; j <= k; ++j) amod(x += 1ll * A[j][m] * B[k - j][m] % md);
      A[k][m] = x;
    }
  }
  for (int j = 0; j <= L; ++j) isos(A[j]);
  for (int i = 0; i < N; ++i) ab[i] = A[pc[i]][i];
  for (int m = 0; m < N; ++m) {
    for (int s = m;; s = (s - 1) & m) {
      amod(ab[m] += 1ll * c[s] * c[m ^ s] % md);
      if (s == 0) break;
    }
  }
  for (int i = 0; i < N; ++i) de[i] = c[i];
  for (int i = 0; i < L; ++i) {
    for (int m = 0, s; m < N; ++m) {
      if (m >> i & 1) continue;
      s = m ^ (1 << i);
      amod(x = de[m] + de[s]);
      amod(y = de[m] - de[s]);
      de[m] = x, de[s] = y;
    }
  }
  for (int i = 0; i < N; ++i) de[i] = 1ll * de[i] * de[i] % md * rN % md;
  for (int i = 0; i < L; ++i) {
    for (int m = 0, s; m < N; ++m) {
      if (m >> i & 1) continue;
      s = m ^ (1 << i);
      amod(x = de[m] + de[s]);
      amod(y = de[m] - de[s]);
      de[m] = x, de[s] = y;
    }
  }
  for (int i = 0; i < N; ++i) {
    ab[i] = 1ll * ab[i] * f[i] % md;
    c[i] = 1ll * c[i] * f[i] % md;
    de[i] = 1ll * de[i] * f[i] % md;
  }
  for (int i = 0; i < L; ++i) {
    for (int m = 0, s; m < N; ++m) {
      if (m >> i & 1) continue;
      s = m ^ (1 << i);
      amod(ab[m] += ab[s]);
      amod(c[m] += c[s]);
      amod(de[m] += de[s]);
    }
  }
  for (int i = 0; i < N; ++i) c[i] = 1ll * ab[i] * c[i] % md * de[i] % md;
  for (int i = 0; i < L; ++i) {
    for (int m = 0, s; m < N; ++m) {
      if (m >> i & 1) continue;
      s = m ^ (1 << i);
      amod(c[m] -= c[s]);
    }
  }
  int re = 0;
  for (int i = 0; i < L; ++i) amod(re += c[1 << i]);
  printf("%d\n", re);
  return 0;
}