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 sz = 17;
const int dim = 1 << sz;
int n, i, j, k;
int s[1000011];
long long fib[1000011];
long long aux[1000011];
long long aux2[1000011];
long long p1[1000011];
long long p2[1000011];
long long p3[1000011];
long long sol[1000011];
long long conv_a[sz + 1][dim], conv_b[sz + 1][dim];
long long bts_cnt(long long x) {
  long long ans = 0;
  while (x > 0) {
    if (x & 1) ans++;
    x >>= 1;
  }
  return ans;
}
long long poww(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % 1000000007;
    b >>= 1;
    a = (a * a) % 1000000007;
  }
  return ans;
}
void fwht(long long *data, bool inv = false) {
  long long n, i, j, len, u, v;
  n = dim;
  for (len = 1; 2 * len <= n; len <<= 1) {
    for (i = 0; i < n; i += 2 * len) {
      for (j = 0; j < len; j++) {
        u = data[i + j];
        v = data[i + len + j];
        data[i + j] = u + v;
        data[i + len + j] = u + 1000000007 - v;
        data[i + j] %= 1000000007;
        data[i + len + j] %= 1000000007;
      }
    }
  }
  if (inv) {
    long long xx = poww(n, 1000000007 - 2);
    for (i = 0; i < n; i++) data[i] = (data[i] * xx) % 1000000007;
  }
}
void dp_subset(long long *data, long long sgn) {
  int i, j;
  for (i = 0; i < sz; i++) {
    for (j = 0; j < dim; j++) {
      if (j & (1 << i)) {
        data[j] += 1000000007 + sgn * data[j ^ (1 << i)];
        data[j] %= 1000000007;
      }
    }
  }
}
void dp_supraset(long long *data, long long sgn) {
  int i, j;
  for (i = 0; i < sz; i++) {
    for (j = 0; j < dim; j++) {
      if ((j & (1 << i)) == 0) {
        data[j] += 1000000007 + sgn * data[j ^ (1 << i)];
        data[j] %= 1000000007;
      }
    }
  }
}
int main() {
  fib[0] = 0;
  fib[1] = 1;
  for (i = 2; i <= dim; i++) fib[i] = (fib[i - 1] + fib[i - 2]) % 1000000007;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &s[i]);
  for (i = 1; i <= n; i++) conv_a[bts_cnt(s[i])][s[i]]++;
  for (i = 0; i <= sz; i++) dp_subset(conv_a[i], +1);
  for (i = 0; i < dim; i++) {
    for (j = 0; j <= sz; j++) {
      long long work = 0;
      for (k = 0; k <= j; k++) {
        work += conv_a[k][i] * conv_a[j - k][i];
        work %= 1000000007;
      }
      conv_b[j][i] = work;
    }
  }
  for (i = 0; i <= sz; i++) dp_subset(conv_b[i], -1);
  for (i = 0; i < dim; i++) p1[i] = conv_b[bts_cnt(i)][i];
  for (i = 1; i <= n; i++) p2[s[i]]++;
  memset(aux, 0, sizeof(aux));
  for (i = 1; i <= n; i++) aux[s[i]]++;
  fwht(aux);
  for (i = 0; i < dim; i++) aux[i] = (aux[i] * aux[i]) % 1000000007;
  fwht(aux, true);
  for (i = 0; i < dim; i++) p3[i] = aux[i];
  for (i = 0; i < dim; i++) {
    p1[i] = (p1[i] * fib[i]) % 1000000007;
    p2[i] = (p2[i] * fib[i]) % 1000000007;
    p3[i] = (p3[i] * fib[i]) % 1000000007;
  }
  dp_supraset(p1, +1);
  dp_supraset(p2, +1);
  dp_supraset(p3, +1);
  for (i = 0; i < dim; i++) {
    sol[i] = p1[i] * p2[i];
    sol[i] %= 1000000007;
    sol[i] *= p3[i];
    sol[i] %= 1000000007;
  }
  dp_supraset(sol, -1);
  long long ans = 0;
  for (i = 0; i < sz; i++) ans += sol[1 << i];
  ans %= 1000000007;
  printf("%lld", ans);
  return 0;
}