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 mod = 1000000007;
const int N = 200000;
struct Poly {
  int a[18];
} cnt1[N];
long long cnt2[N], cnt3[N], f[N], a[N], b[N], c[N], n, size[N];
int qpower(int a, int b) {
  int ans = 1;
  for (; b; b >>= 1, a = 1ll * a * a % mod)
    if (b & 1) ans = 1ll * ans * a % mod;
  return ans;
}
void qmod(int &a) { a += a >> 31 & mod; }
void FWT_or(Poly a[]) {
  int n = 1 << 17;
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < n; j += i << 1)
      for (int k = 0; k < i; k++)
        for (int t = 0; t <= 17; t++) a[i + j + k].a[t] += a[j + k].a[t];
}
void IFWT_or(Poly a[]) {
  int n = 1 << 17;
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < n; j += i << 1)
      for (int k = 0; k < i; k++)
        for (int t = 0; t <= 17; t++) qmod(a[i + j + k].a[t] -= a[j + k].a[t]);
}
void FWT_and(long long a[]) {
  int n = 1 << 17;
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < n; j += i << 1)
      for (int k = 0; k < i; k++) a[j + k] += a[i + j + k];
}
void IFWT_and(long long a[]) {
  int n = 1 << 17;
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < n; j += i << 1)
      for (int k = 0; k < i; k++) a[j + k] -= a[i + j + k];
}
void FWT_xor(long long a[]) {
  int n = 1 << 17;
  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 x = a[j + k], y = a[i + j + k];
        a[j + k] = (x + y), a[i + j + k] = (x - y);
      }
}
void IFWT_xor(long long a[]) {
  int n = 1 << 17;
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < n; j += i << 1)
      for (int k = 0; k < i; k++) {
        long long x = a[j + k], y = a[i + j + k];
        a[j + k] = (x + y), a[i + j + k] = (x - y);
      }
  int iv = qpower(n, mod - 2);
  for (int i = 0; i < n; i++) a[i] = 1ll * a[i] % mod * iv % mod;
}
int main() {
  scanf("%d", &n);
  size[0] = 0;
  for (int i = 1; i < (1 << 17); i++) size[i] = size[i >> 1] + (i & 1);
  for (int i = 1, x; i <= n; i++)
    scanf("%d", &x), cnt1[x].a[size[x]]++, cnt2[x]++, cnt3[x]++;
  f[0] = 0, f[1] = 1;
  for (int i = 2; i < (1 << 17); i++) f[i] = (f[i - 1] + f[i - 2]) % mod;
  FWT_or(cnt1), FWT_xor(cnt2);
  for (int i = 0; i < (1 << 17); i++) {
    long long t;
    for (int j = 17; j >= 0; j--) {
      t = 0;
      for (int k = 0; k <= j; k++) t += 1ll * cnt1[i].a[k] * cnt1[i].a[j - k];
      cnt1[i].a[j] = t % mod;
    }
  }
  for (int i = 0; i < (1 << 17); i++) cnt2[i] = cnt2[i] * cnt2[i] % mod;
  IFWT_or(cnt1);
  IFWT_xor(cnt2);
  for (int i = 0; i < (1 << 17); i++)
    a[i] = 1ll * f[i] * cnt1[i].a[size[i]] % mod,
    b[i] = 1ll * cnt2[i] % mod * f[i] % mod, c[i] = 1ll * cnt3[i] * f[i] % mod;
  FWT_and(a), FWT_and(b), FWT_and(c);
  for (int i = 0; i < (1 << 17); i++)
    f[i] = 1ll * a[i] % mod * (b[i] % mod) % mod * (c[i] % mod) % mod;
  IFWT_and(f);
  int ans = 0;
  for (int i = 0; i < 17; i++) ans = (ans + f[1 << i]) % mod;
  cout << (ans + mod) % mod << endl;
}