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 n, m;
int fibo[200005], t[20][200005], f[20][200005], a[1000006], g[200005],
    h[200005], s[200005];
void FWT_or(int*, int, int);
void FWT_and(int*, int, int);
void FWT_xor(int*, int, int);
void init();
int main() {
  init();
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    int x = a[i], cnt = 0;
    m = max(m, x);
    for (int j = 0; j <= 17; ++j)
      if (x & (1 << j)) ++cnt;
    ++f[cnt][x];
    ++h[x];
    ++s[x];
  }
  int bit = 1, l = 1;
  while (bit <= m) bit <<= 1, ++l;
  for (int i = 0; i <= l; ++i) FWT_or(f[i], 1, bit);
  for (int i = 1; i <= l; ++i)
    for (int j = 0; j <= i; ++j)
      for (int k = 0; k < bit; ++k)
        t[i][k] = (1ll * t[i][k] + 1ll * f[j][k] * f[i - j][k] % 1000000007) %
                  1000000007;
  for (int i = 0; i <= l; ++i) {
    FWT_or(t[i], -1, bit);
    for (int j = 0; j < bit; ++j) {
      int cnt = 0;
      for (int k = 0; k <= l; ++k)
        if (j & (1 << k)) ++cnt;
      g[j] = (1ll * g[j] + t[i][j] * (cnt == i)) % 1000000007;
    }
  }
  FWT_xor(h, 1, bit);
  for (int i = 0; i < bit; ++i) h[i] = 1ll * h[i] * h[i] % 1000000007;
  FWT_xor(h, -1, bit);
  for (int i = 0; i < bit; ++i)
    s[i] = 1ll * fibo[i] * s[i] % 1000000007,
    g[i] = 1ll * fibo[i] * g[i] % 1000000007,
    h[i] = 1ll * fibo[i] * h[i] % 1000000007;
  FWT_and(h, 1, bit);
  FWT_and(g, 1, bit);
  FWT_and(s, 1, bit);
  for (int i = 0; i < bit; ++i)
    s[i] = 1ll * s[i] * g[i] % 1000000007 * h[i] % 1000000007;
  FWT_and(s, -1, bit);
  int ans = 0;
  for (int i = 1; i < bit; i <<= 1) ans = (1ll * ans + s[i]) % 1000000007;
  cout << ans << endl;
  return 0;
}
void FWT_or(int* x, int f, int len) {
  for (int i = 1; i < len; i <<= 1)
    for (int j = 0; j < len; j += i << 1)
      for (int k = 0; k < i; ++k)
        x[i + j + k] =
            (1ll * x[i + j + k] + x[j + k] * f + 1000000007) % 1000000007;
  return;
}
void FWT_and(int* x, int f, int len) {
  for (int i = 1; i < len; i <<= 1)
    for (int j = 0; j < len; j += i << 1)
      for (int k = 0; k < i; ++k)
        x[j + k] =
            (1ll * x[j + k] + x[i + j + k] * f + 1000000007) % 1000000007;
  return;
}
void FWT_xor(int* x, int f, int len) {
  for (int i = 1; i < len; i <<= 1)
    for (int j = 0; j < len; j += i << 1)
      for (int k = 0; k < i; ++k) {
        int p = x[j + k], q = x[i + j + k];
        x[j + k] = (1ll * p + q) % 1000000007;
        x[i + j + k] = (1ll * p - q + 1000000007) % 1000000007;
        if (f == -1)
          x[j + k] = 1ll * x[j + k] * 500000004 % 1000000007,
                x[i + j + k] = 1ll * x[i + j + k] * 500000004 % 1000000007;
      }
  return;
}
void init() {
  fibo[1] = fibo[2] = 1;
  for (int i = 3; i <= (1 << 17); ++i)
    fibo[i] = (1ll * fibo[i - 1] + fibo[i - 2]) % 1000000007;
  return;
}