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 P = 1000000007;
inline int Pow(int a, int b) {
  int c = 1;
  for (; b; b >>= 1, a = a * 1ll * a % P)
    if (b & 1) c = c * 1ll * a % P;
  return c;
}
inline void FWT(int *A, int f, int N) {
  int p2 = Pow(2, P - 2);
  for (int i = 1; i < N; i <<= 1)
    for (int j = 0; j < N; j += (i << 1))
      for (int k = 0; k < i; k++) {
        int x0 = A[j + k];
        int x1 = A[i + j + k];
        if (f == 0) {
          A[j + k] = (x0 - x1 + P) % P;
          A[i + j + k] = (x0 + x1) % P;
        } else {
          A[j + k] = (x0 + x1) * 1ll * p2 % P;
          A[i + j + k] = (x1 - x0) * 1ll * p2 % P;
          if (A[i + j + k] < 0) A[i + j + k] += P;
        }
      }
}
const int N = 1 << 17;
int cnt[N];
int ss;
int n = 17;
int f[N][18];
int bit[N];
int gt[18];
int p1[N];
int p2[N];
int p3[N];
int fib[N];
void tr(int *a) {
  for (int i = (int)0; i <= (int)n - 1; i++)
    for (int S = (int)(1 << n) - 1; S >= (int)0; S--)
      if (!(S & (1 << i))) a[S] = (a[S] + a[S ^ (1 << i)]) % P;
}
void ntr(int *a) {
  for (int i = (int)n - 1; i >= (int)0; i--)
    for (int S = (int)0; S <= (int)(1 << n) - 1; S++)
      if (!(S & (1 << i))) a[S] = (a[S] + P - a[S ^ (1 << i)]) % P;
}
int main() {
  scanf("%d", &ss);
  for (int i = (int)1; i <= (int)(1 << n) - 1; i++)
    bit[i] = bit[i >> 1] + (i & 1);
  fib[0] = 0;
  fib[1] = 1;
  for (int i = (int)2; i <= (int)(1 << n) - 1; i++)
    fib[i] = (fib[i - 1] + fib[i - 2]) % P;
  while (ss--) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
  }
  for (int i = (int)0; i <= (int)(1 << n) - 1; i++) {
    f[i][bit[i]] = cnt[i];
  }
  for (int i = (int)0; i <= (int)n - 1; i++)
    for (int S = (int)0; S <= (int)(1 << n) - 1; S++)
      if (S & (1 << i))
        for (int j = (int)0; j <= (int)n; j++)
          f[S][j] = (f[S][j] + f[S ^ (1 << i)][j]) % P;
  for (int S = (int)0; S <= (int)(1 << n) - 1; S++) {
    memset(gt, 0, sizeof gt);
    for (int i = (int)0; i <= (int)n; i++)
      for (int j = (int)0; j <= (int)n - i; j++)
        gt[i + j] = (gt[i + j] + f[S][i] * 1ll * f[S][j]) % P;
    for (int i = (int)0; i <= (int)n; i++) f[S][i] = gt[i];
  }
  for (int i = (int)0; i <= (int)n - 1; i++)
    for (int S = (int)0; S <= (int)(1 << n) - 1; S++)
      if (S & (1 << i))
        for (int j = (int)0; j <= (int)n; j++)
          f[S][j] = (f[S][j] + P - f[S ^ (1 << i)][j]) % P;
  for (int S = (int)0; S <= (int)(1 << n) - 1; S++)
    p1[S] = f[S][bit[S]] * 1ll * fib[S] % P;
  for (int S = (int)0; S <= (int)(1 << n) - 1; S++)
    p2[S] = cnt[S] * 1ll * fib[S] % P;
  for (int S = (int)0; S <= (int)(1 << n) - 1; S++) p3[S] = cnt[S];
  FWT(p3, 0, 1 << n);
  for (int S = (int)0; S <= (int)(1 << n) - 1; S++)
    p3[S] = p3[S] * 1ll * p3[S] % P;
  FWT(p3, 1, 1 << n);
  for (int S = (int)0; S <= (int)(1 << n) - 1; S++)
    p3[S] = p3[S] * 1ll * fib[S] % P;
  tr(p1);
  tr(p2);
  tr(p3);
  for (int i = (int)0; i <= (int)(1 << n) - 1; i++)
    p1[i] = (p1[i] * 1ll * p2[i] % P) * 1ll * p3[i] % P;
  ntr(p1);
  int ans = 0;
  for (int i = (int)0; i <= (int)n - 1; i++) ans = (ans + p1[1 << i]) % P;
  printf("%d\n", ans);
  return 0;
}