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 md = 1e9 + 7;
const int rN = 742744451;
void amod(int &x) {
  while (x >= md) x -= md;
  while (x < 0) x += md;
}
void aconv(int n, int *u, int *v, int *w, int *x) {
  if (n <= 32) {
    for (int i = 0; i < n; ++i) w[i] = 0;
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j) amod(w[i & j] += 1ll * u[i] * v[j] % md);
    return;
  }
  int m = n >> 1;
  aconv(m, u + m, v + m, w + m, x);
  for (int i = 0; i < m; ++i) {
    amod(x[i] = u[i] + u[m + i]);
    amod(x[m + i] = v[i] + v[m + i]);
  }
  aconv(m, x, x + m, w, x + n);
  for (int i = 0; i < m; ++i) amod(w[i] -= w[m + i]);
}
int ab[N], c[N], de[N], f[N];
int d[N], bf[N + N];
int main() {
  f[1] = 1;
  for (int i = 2; i < N; ++i) amod(f[i] = f[i - 1] + f[i - 2]);
  int n, x, y;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    ++c[x];
  }
  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;
  }
  aconv(N, ab, c, d, bf);
  aconv(N, d, de, c, bf);
  int rs = 0;
  for (int i = 0; i < L; ++i) amod(rs += c[1 << i]);
  printf("%d\n", rs);
  return 0;
}