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;
struct fwht {
  long long int P1[(1 << 17)], P2[(1 << 17)];
  long long int Add(long long int a, long long int b) {
    return (a + b) >= 1000000007 ? a + b - 1000000007 : a + b;
  }
  long long int Sub(long long int a, long long int b) {
    return (a - b) <= -1000000007 ? a - b + 1000000007 : a - b;
  }
  long long int Half(long long int a) {
    return (a & 1) ? (a + 1000000007) / 2 : a / 2;
  }
  void walsh_transform(long long int* ar, int n, int flag = 2) {
    if (n == 0) return;
    int i, m = n / 2;
    walsh_transform(ar, m, flag);
    walsh_transform(ar + m, m, flag);
    for (i = 0; i < m; i++) {
      long long int x = ar[i], y = ar[i + m];
      if (flag == 0) ar[i] = x, ar[i + m] = Add(x, y);
      if (flag == 1) ar[i] = Add(x, y), ar[i + m] = y;
      if (flag == 2) ar[i] = Add(x, y), ar[i + m] = Sub(x, y);
      ar[i] %= 1000000007;
      ar[i + m] %= 1000000007;
    }
  }
  void inverse_walsh_transform(long long int* ar, int n, int flag = 2) {
    if (n == 0) return;
    int i, m = n / 2;
    inverse_walsh_transform(ar, m, flag);
    inverse_walsh_transform(ar + m, m, flag);
    for (i = 0; i < m; i++) {
      long long int x = ar[i], y = ar[i + m];
      if (flag == 0) ar[i] = x, ar[i + m] = Sub(y, x);
      if (flag == 1) ar[i] = Sub(x, y), ar[i + m] = y;
      if (flag == 2) ar[i] = Half(Add(x, y)), ar[i + m] = Half(Sub(x, y));
      ar[i] %= 1000000007;
      ar[i + m] %= 1000000007;
    }
  }
  vector<long long int> convolution(int n, long long int* A, long long int* B,
                                    int flag = 2) {
    assert(__builtin_popcount(n) == 1);
    for (int i = 0; i < n; i++) P1[i] = A[i] % 1000000007;
    for (int i = 0; i < n; i++) P2[i] = B[i] % 1000000007;
    walsh_transform(P1, n, flag);
    walsh_transform(P2, n, flag);
    for (int i = 0; i < n; i++) P1[i] = (P1[i] * P2[i]) % 1000000007;
    inverse_walsh_transform(P1, n, flag);
    for (int i = 0; i < n; i++) P1[i] %= 1000000007;
    return vector<long long int>(P1, P1 + n);
  }
  vector<long long int> or_convolution(int n, long long int* A,
                                       long long int* B) {
    return convolution(n, A, B, 0);
  }
  vector<long long int> and_convolution(int n, long long int* A,
                                        long long int* B) {
    return convolution(n, A, B, 1);
  }
  vector<long long int> xor_convolution(int n, long long int* A,
                                        long long int* B) {
    return convolution(n, A, B, 2);
  }
  int PopCount[(1 << 17)];
  long long int F1[17 + 1][(1 << 17)];
  long long int F2[17 + 1][(1 << 17)];
  long long int G[17 + 1][(1 << 17)];
  vector<long long int> subset_or_convolution(int n, long long int* A,
                                              long long int* B) {
    for (int i = 1; i < (1 << 17); i++)
      PopCount[i] = PopCount[i >> 1] + (i & 1);
    for (int i = 0; i < n; i++) F1[PopCount[i]][i] = A[i] % 1000000007;
    for (int i = 0; i < n; i++) F2[PopCount[i]][i] = B[i] % 1000000007;
    for (int i = 0; i <= 17; i++) walsh_transform(F1[i], n, 0);
    for (int i = 0; i <= 17; i++) walsh_transform(F2[i], n, 0);
    for (int i = 0; i <= 17; i++)
      for (int j = 0; j <= i; j++)
        for (int k = 0; k < n; k++) {
          G[i][k] += (F1[j][k] * F2[i - j][k]) % 1000000007;
          if (G[i][k] >= 1000000007) G[i][k] -= 1000000007;
        }
    for (int i = 0; i <= 17; i++) inverse_walsh_transform(G[i], n, 0);
    for (int i = 0; i < n; i++) F1[0][i] = G[PopCount[i]][i] % 1000000007;
    return vector<long long int>(F1[0], F1[0] + n);
  }
};
fwht fft;
long long int Count[(1 << 17)];
long long int Fib[(1 << 17)];
long long int A[(1 << 17)];
long long int B[(1 << 17)];
long long int C[(1 << 17)];
int main() {
  int n, x;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    Count[x]++;
  }
  Fib[1] = 1;
  for (int i = 2; i < (1 << 17); i++)
    Fib[i] = (Fib[i - 1] + Fib[i - 2]) % 1000000007;
  vector<long long int> aa = fft.subset_or_convolution((1 << 17), Count, Count);
  vector<long long int> bb = fft.xor_convolution((1 << 17), Count, Count);
  vector<long long int> cc = vector<long long int>(Count, Count + (1 << 17));
  for (int i = 0; i < (1 << 17); i++) A[i] = (aa[i] * Fib[i]) % 1000000007;
  for (int i = 0; i < (1 << 17); i++) B[i] = (bb[i] * Fib[i]) % 1000000007;
  for (int i = 0; i < (1 << 17); i++) C[i] = (cc[i] * Fib[i]) % 1000000007;
  vector<long long int> Res1 = fft.and_convolution((1 << 17), A, B);
  for (int i = 0; i < (1 << 17); i++) A[i] = Res1[i];
  vector<long long int> Res2 = fft.and_convolution((1 << 17), A, C);
  long long int Ans = 0;
  for (int i = 0; i < 17; i++) Ans = (Ans + Res2[1 << i]) % 1000000007;
  if (Ans < 0) Ans += 1000000007;
  printf("%lld\n", Ans);
}