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>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
using namespace std;
const int inf = 1e9 + 10, lg = 17, size = 1 << lg, M = 1e9 + 7;
const int AND[2][4] = {{0, 1, 1, 1}, {-1, 1, 1, 0}};
const int OR[2][4] = {{1, 1, 1, 0}, {0, 1, 1, -1}};
const int XOR[2][4] = {{1, 1, 1, -1}, {1, 1, 1, -1}};
int n, cnt[4][size], cor[lg + 1][size], cbit[size];
int tmp[size];
int power(int a, int b) {
  int ans = 1;
  while (b > 0) {
    if (b & 1) {
      ans = 1ll * ans * a % M;
    }
    a = 1ll * a * a % M;
    b >>= 1;
  }
  return ans;
}
void transform(int A[], const int z[2][4], bool inv) {
  int a, b;
  for (int len = 1; len < size; len <<= 1) {
    for (int i = 0; i < size; i += (len << 1)) {
      for (int j = i; j < i + len; j++) {
        a = A[j], b = A[j + len];
        A[j] = a * z[inv][0] + b * z[inv][1];
        if (A[j] < 0) {
          A[j] += M;
        }
        if (A[j] >= M) {
          A[j] -= M;
        }
        A[j + len] = a * z[inv][2] + b * z[inv][3];
        if (A[j + len] < 0) {
          A[j + len] += M;
        }
        if (A[j + len] >= M) {
          A[j + len] -= M;
        }
      }
    }
  }
  if (inv && z == XOR) {
    int sinv = power(size, M - 2);
    for (int i = 0; i < size; i++) {
      A[i] = 1ll * A[i] * sinv % M;
    }
  }
}
void or_conv0(int A[]) {
  for (int len = 1; len < size; len <<= 1) {
    for (int i = 0; i < size; i += (len << 1)) {
      for (int j = i; j < i + len; j++) {
        int a = A[j];
        A[j] = a + A[j + len];
        if (A[j] >= M) {
          A[j] -= M;
        }
        A[j + len] = a;
      }
    }
  }
}
void or_conv1(int A[]) {
  for (int len = 1; len < size; len <<= 1) {
    for (int i = 0; i < size; i += (len << 1)) {
      for (int j = i; j < i + len; j++) {
        int a = A[j];
        A[j] = A[j + len];
        A[j + len] = a - A[j + len];
        if (A[j + len] < 0) {
          A[j + len] += M;
        }
      }
    }
  }
}
int fib[size];
int32_t main() {
  fib[1] = 1;
  for (int i = 2; i < size; i++) {
    fib[i] = (fib[i - 1] + fib[i - 2]) % M;
  }
  for (int i = 0; i < size; i++) {
    cbit[i] = cbit[i >> 1] + (i & 1);
  }
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    cor[cbit[a]][a]++;
    cnt[1][a]++;
    cnt[2][a]++;
  }
  transform(cnt[2], XOR, 0);
  for (int i = 0; i < size; i++) {
    cnt[2][i] = power(cnt[2][i], 2);
  }
  transform(cnt[2], XOR, 1);
  for (int i = 0; i < lg + 1; i++) {
    or_conv0(cor[i]);
  }
  for (int j = 0; j < lg + 1; j++) {
    for (int k = j; k < lg - j + 1; k++) {
      for (int i = 0; i < size; i++) {
        tmp[i] = 1ll * cor[j][i] * cor[k][i] % M;
      }
      or_conv1(tmp);
      for (int i = 0; i < size; i++) {
        if (cbit[i] == j + k) {
          cnt[0][i] = (cnt[0][i] + tmp[i]) % M;
          if (j != k) {
            cnt[0][i] = (cnt[0][i] + tmp[i]) % M;
          }
        }
      }
    }
  }
  for (int j = 0; j < 3; j++) {
    for (int i = 0; i < size; i++) {
      cnt[j][i] = 1ll * fib[i] * cnt[j][i] % M;
    }
    transform(cnt[j], AND, 0);
  }
  for (int i = 0; i < size; i++) {
    cnt[3][i] = 1ll * cnt[0][i] * cnt[1][i] % M;
    cnt[3][i] = 1ll * cnt[2][i] * cnt[3][i] % M;
  }
  transform(cnt[3], AND, 1);
  int ans = 0;
  for (int i = 0; i < lg; i++) {
    ans = (ans + cnt[3][1 << i]) % M;
  }
  printf("%d\n", ans);
}