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 N = 1000050;
const int M = (1 << 17) + 50;
const int MOD = 1000000007;
const int inv_2 = (MOD + 1) / 2;
template <typename T>
inline void read(T& x) {
  T f = 1, c = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    c = c * 10 + ch - '0';
    ch = getchar();
  }
  x = f * c;
}
template <typename T>
inline void Mod(T& x) {
  if (x >= MOD) x -= MOD;
}
int n, len = 1 << 17, s[M], a[M], b[M], c[M], d[20][M], e[20][M], f[M], cnt[M];
void fwt_xor(int* a, int len, int k) {
  for (int i = 1; i < len; i <<= 1)
    for (int j = 0; j < len; j += (i << 1))
      for (int o = 0; o < i; o++) {
        int w1 = a[j + o], w2 = a[j + o + i];
        Mod(a[j + o] = w1 + w2), Mod(a[j + o + i] = w1 + MOD - w2);
        if (k == -1)
          a[j + o] = 1ll * a[j + o] * inv_2 % MOD,
                a[j + o + i] = 1ll * a[j + o + i] * inv_2 % MOD;
      }
}
void fwt_or(int* a, int len, int k) {
  for (int i = 1; i < len; i <<= 1)
    for (int j = 0; j < len; j += (i << 1))
      for (int o = 0; o < i; o++) {
        if (k == 1)
          Mod(a[j + o + i] += a[j + o]);
        else
          Mod(a[j + o + i] += MOD - a[j + o]);
      }
}
void fwt_and(int* a, int len, int k) {
  for (int i = 1; i < len; i <<= 1)
    for (int j = 0; j < len; j += (i << 1))
      for (int o = 0; o < i; o++) {
        if (k == 1)
          Mod(a[j + o] += a[j + o + i]);
        else
          Mod(a[j + o] += MOD - a[j + o + i]);
      }
}
int main() {
  read(n);
  for (int x, i = 1; i <= n; i++) read(x), s[x]++;
  for (int i = 1; i < len; i++) cnt[i] = cnt[i - (i & -i)] + 1;
  f[1] = 1;
  for (int i = 2; i < len; i++) Mod(f[i] = f[i - 1] + f[i - 2]);
  for (int i = 0; i < len; i++) d[cnt[i]][i] = s[i];
  for (int i = 0; i <= 17; i++) fwt_or(d[i], len, 1);
  for (int i = 0; i <= 17; i++)
    for (int j = 0; j <= i; j++)
      for (int k = 0; k < len; k++)
        Mod(e[i][k] += 1ll * d[j][k] * d[i - j][k] % MOD);
  for (int i = 0; i <= 17; i++) fwt_or(e[i], len, -1);
  for (int i = 0; i < len; i++) a[i] = 1ll * e[cnt[i]][i] * f[i] % MOD;
  for (int i = 0; i < len; i++) b[i] = 1ll * s[i] * f[i] % MOD;
  fwt_xor(s, len, 1);
  for (int i = 0; i < len; i++) c[i] = 1ll * s[i] * s[i] % MOD;
  fwt_xor(c, len, -1);
  for (int i = 0; i < len; i++) c[i] = 1ll * c[i] * f[i] % MOD;
  fwt_and(a, len, 1), fwt_and(b, len, 1), fwt_and(c, len, 1);
  for (int i = 0; i < len; i++) a[i] = 1ll * a[i] * b[i] % MOD * c[i] % MOD;
  fwt_and(a, len, -1);
  int ans = 0;
  for (int i = 1; i < len; i <<= 1) Mod(ans += a[i]);
  printf("%d\n", ans);
  return 0;
}