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;
int gi() {
  int res = 0, s = 1;
  char ch;
  for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar())
    ;
  if (ch == '-') s = -1, ch = getchar();
  for (; ch >= '0' && ch <= '9'; ch = getchar()) res = res * 10 + ch - 48;
  return res * s;
}
int n, A[131100], B[131100], C[131100], all, Fib[131100], f[20][131100],
    h[20][131100], cnt[131100];
void fwt(int x[]) {
  for (int p = 1; p <= all; p <<= 1)
    for (int s = 0; s <= all; ++s) {
      if (s & p) continue;
      int u = x[s], v = x[s | p];
      x[s] = u + v;
      x[s] >= 1000000007 ? x[s] -= 1000000007 : 0;
      x[s | p] = u - v;
      x[s | p] < 0 ? x[s | p] += 1000000007 : 0;
    }
}
void fmt(int x[]) {
  for (int p = 1; p <= all; p <<= 1)
    for (int s = 0; s <= all; ++s)
      if (!(s & p))
        x[s] += x[s | p], x[s] >= 1000000007 ? x[s] -= 1000000007 : 0;
}
void ufmt(int x[]) {
  for (int p = 1; p <= all; p <<= 1)
    for (int s = 0; s <= all; ++s)
      if (!(s & p)) x[s] -= x[s | p], x[s] < 0 ? x[s] += 1000000007 : 0;
}
int main() {
  n = gi();
  all = 131071;
  for (int i = 1, x; i <= n; ++i) x = gi(), A[x]++, B[x]++, C[x]++;
  Fib[0] = 0, Fib[1] = 1;
  for (int i = 2; i <= all; ++i) {
    Fib[i] = Fib[i - 1] + Fib[i - 2];
    Fib[i] >= 1000000007 ? Fib[i] -= 1000000007 : 0;
  }
  for (int i = 1; i <= all; ++i) cnt[i] = cnt[i - (i & -i)] + 1;
  for (int i = 0; i <= all; ++i) f[cnt[i]][i] = A[i];
  for (int i = 0; i <= 17; ++i)
    for (int p = 1; p <= all; p <<= 1)
      for (int s = 0; s <= all; ++s)
        if (!(s & p))
          f[i][s | p] += f[i][s],
              f[i][s | p] >= 1000000007 ? f[i][s | p] -= 1000000007 : 0;
  memset(A, 0, sizeof(A));
  for (int i = 0; i <= 17; ++i)
    for (int j = 0; j <= 17 - i; ++j)
      for (int s = 0; s <= all; ++s)
        h[i + j][s] += 1ll * f[i][s] * f[j][s] % 1000000007,
            h[i + j][s] >= 1000000007 ? h[i + j][s] -= 1000000007 : 0;
  for (int i = 0; i <= 17; ++i)
    for (int p = 1; p <= all; p <<= 1)
      for (int s = 0; s <= all; ++s)
        if (!(s & p))
          h[i][s | p] -= h[i][s],
              h[i][s | p] < 0 ? h[i][s | p] += 1000000007 : 0;
  for (int i = 0; i <= all; ++i) A[i] = h[cnt[i]][i];
  fwt(B);
  for (int s = 0; s <= all; ++s) B[s] = 1ll * B[s] * B[s] % 1000000007;
  fwt(B);
  for (int s = 0; s <= all; ++s) B[s] = 1ll * B[s] * 742744451 % 1000000007;
  for (int i = 0; i <= all; ++i) {
    A[i] = 1ll * A[i] * Fib[i] % 1000000007;
    B[i] = 1ll * B[i] * Fib[i] % 1000000007;
    C[i] = 1ll * C[i] * Fib[i] % 1000000007;
  }
  fmt(A), fmt(B), fmt(C);
  for (int i = 0; i <= all; ++i)
    C[i] = 1ll * A[i] * C[i] % 1000000007 * B[i] % 1000000007;
  ufmt(C);
  int ans = 0;
  for (int i = 0; i < 17; ++i) {
    ans += C[1 << i];
    ans >= 1000000007 ? ans -= 1000000007 : 0;
  }
  printf("%d\n", ans);
  return 0;
}