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 MAXN = 20;
const int MAXS = 2 << 17;
const int P = 1e9 + 7;
const int inv = 5e8 + 4;
template <typename T>
void chkmax(T &x, T y) {
  x = max(x, y);
}
template <typename T>
void chkmin(T &x, T y) {
  x = min(x, y);
}
template <typename T>
void read(T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -f;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  x *= f;
}
template <typename T>
void write(T x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
void writeln(T x) {
  write(x);
  puts("");
}
int cnt[MAXS], bits[MAXS];
int resor[MAXS], resxor[MAXS], res[MAXS];
int f[MAXN][MAXS], seq[MAXS];
void FWTXOR(int *a, int N) {
  for (int len = 2; len <= N; len <<= 1)
    for (int s = 0; s < N; s += len)
      for (int i = s, j = s + len / 2; j < s + len; i++, j++) {
        int tmp = a[i], tnp = a[j];
        a[i] = (tmp + tnp) % P;
        a[j] = (tmp - tnp + P) % P;
      }
}
void UFWTXOR(int *a, int N) {
  for (int len = 2; len <= N; len <<= 1)
    for (int s = 0; s < N; s += len)
      for (int i = s, j = s + len / 2; j < s + len; i++, j++) {
        int tmp = a[i], tnp = a[j];
        a[i] = 1ll * (tmp + tnp) * inv % P;
        a[j] = 1ll * (tmp - tnp + P) * inv % P;
      }
}
void FWTOR(int *a, int N) {
  for (int len = 2; len <= N; len <<= 1)
    for (int s = 0; s < N; s += len)
      for (int i = s, j = s + len / 2; j < s + len; i++, j++)
        a[j] = (a[i] + a[j]) % P;
}
void UFWTOR(int *a, int N) {
  for (int len = 2; len <= N; len <<= 1)
    for (int s = 0; s < N; s += len)
      for (int i = s, j = s + len / 2; j < s + len; i++, j++)
        a[j] = (a[j] - a[i] + P) % P;
}
void FWTAND(int *a, int N) {
  for (int len = 2; len <= N; len <<= 1)
    for (int s = 0; s < N; s += len)
      for (int i = s, j = s + len / 2; j < s + len; i++, j++)
        a[i] = (a[i] + a[j]) % P;
}
void UFWTAND(int *a, int N) {
  for (int len = 2; len <= N; len <<= 1)
    for (int s = 0; s < N; s += len)
      for (int i = s, j = s + len / 2; j < s + len; i++, j++)
        a[i] = (a[i] - a[j] + P) % P;
}
int main() {
  int n;
  read(n);
  for (int i = 1; i <= n; i++) {
    int x;
    read(x);
    cnt[x]++;
  }
  memcpy(resxor, cnt, sizeof(cnt));
  FWTXOR(resxor, MAXS);
  for (int s = 0; s < MAXS; s++) resxor[s] = 1ll * resxor[s] * resxor[s] % P;
  UFWTXOR(resxor, MAXS);
  for (int s = 0; s < MAXS; s++) {
    int tmp = s;
    while (tmp != 0) {
      if (tmp & 1) bits[s]++;
      tmp >>= 1;
    }
    f[bits[s]][s] = cnt[s];
  }
  for (int i = 0; i <= 17; i++) FWTOR(f[i], MAXS);
  for (int i = 0; i <= 17; i++) {
    static int tmp[MAXS];
    memset(tmp, 0, sizeof(tmp));
    for (int j = 0; j <= i; j++)
      for (int s = 0; s < MAXS; s++)
        tmp[s] = (tmp[s] + 1ll * f[j][s] * f[i - j][s]) % P;
    UFWTOR(tmp, MAXS);
    for (int s = 0; s < MAXS; s++)
      if (bits[s] == i) resor[s] = tmp[s];
  }
  seq[1] = 1;
  for (int i = 2; i < MAXS; i++) seq[i] = (seq[i - 2] + seq[i - 1]) % P;
  for (int i = 0; i < MAXS; i++) {
    resxor[i] = 1ll * resxor[i] * seq[i] % P;
    resor[i] = 1ll * resor[i] * seq[i] % P;
    cnt[i] = 1ll * cnt[i] * seq[i] % P;
  }
  FWTAND(resxor, MAXS);
  FWTAND(resor, MAXS);
  FWTAND(cnt, MAXS);
  for (int s = 0; s < MAXS; s++)
    res[s] = 1ll * resxor[s] * resor[s] % P * cnt[s] % P;
  UFWTAND(res, MAXS);
  int ans = 0;
  for (int s = 0; s < MAXS; s++)
    if (bits[s] == 1) ans = (ans + res[s]) % P;
  writeln(ans);
  return 0;
}