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>
const int mod = 1e9 + 7;
const int maxn = 1 << 18 | 1;
int n;
long long b[maxn], a[maxn], c[maxn], d[maxn], f[maxn], inv;
inline void read(int &now) {
  char Cget;
  now = 0;
  while (!isdigit(Cget = getchar()))
    ;
  while (isdigit(Cget)) {
    now = now * 10 + Cget - '0';
    Cget = getchar();
  }
}
void fwtxor(long long *p, int len) {
  if (len == 1) return;
  fwtxor(p, (len >> 1));
  fwtxor(p + (len >> 1), (len >> 1));
  for (long long i = 0, t1, t2; i < (len >> 1); i++) {
    t1 = p[i] % mod;
    t2 = p[i + (len >> 1)] % mod;
    (p[i] = t1 + t2) %= mod;
    (p[i + (len >> 1)] = t1 - t2) %= mod;
  }
}
void ifwtxor(long long *p, int len) {
  if (len == 1) return;
  for (long long i = 0, t1, t2; i < (len >> 1); i++) {
    t1 = p[i] % mod;
    t2 = p[i + (len >> 1)] % mod;
    (p[i] = (t1 + t2) % mod * inv) %= mod;
    (p[i + (len >> 1)] = (t1 - t2) % mod * inv) %= mod;
  }
  ifwtxor(p, len >> 1);
  ifwtxor(p + (len >> 1), len >> 1);
}
void fwtor(long long *p, int len) {
  if (len == 1) return;
  fwtor(p, len >> 1);
  fwtor(p + (len >> 1), len >> 1);
  for (int i = 0; i < (len >> 1); i++) (p[i + (len >> 1)] += p[i]) %= mod;
}
void ifwtor(long long *p, int len) {
  if (len == 1) return;
  for (int i = 0; i < (len >> 1); i++) (p[i + (len >> 1)] -= p[i]) %= mod;
  ifwtor(p, len >> 1);
  ifwtor(p + (len >> 1), len >> 1);
}
void fwtand(long long *p, int len) {
  if (len == 1) return;
  fwtand(p, len >> 1);
  fwtand(p + (len >> 1), len >> 1);
  for (int i = 0; i < (len >> 1); i++) (p[i] += p[i + (len >> 1)]) %= mod;
}
void ifwtand(long long *p, int len) {
  if (len == 1) return;
  for (int i = 0; i < (len >> 1); i++) (p[i] -= p[i + (len >> 1)]) %= mod;
  ifwtand(p, len >> 1);
  ifwtand(p + (len >> 1), len >> 1);
}
int main() {
  inv = 1;
  long long x = 2;
  int tmp = mod - 2;
  while (tmp > 0) {
    if (tmp & 1) (inv *= x) %= mod;
    tmp >>= 1;
    (x *= x) %= mod;
  }
  read(n);
  int len = 1 << 17;
  for (int i = 1; i <= n; i++) {
    int x;
    read(x);
    b[x]++;
  }
  f[0] = 0;
  f[1] = 1;
  for (int i = 2; i < maxn; i++) f[i] = (f[i - 1] + f[i - 2]) % mod;
  for (int i = 0; i <= len; i++) {
    a[i] = b[i];
    d[i] = b[i];
  }
  fwtxor(d, len);
  for (int i = 0; i <= len; i++) d[i] *= d[i];
  ifwtxor(d, len);
  for (int i = 0; i < len; i++) {
    for (int x = i; x; x = i & (x - 1)) (c[i] += b[x] * b[i ^ x] % mod) %= mod;
    (c[i] += b[0] * b[i]) %= mod;
  }
  for (int i = 0; i <= len; i++) {
    c[i] = c[i] % mod * f[i] % mod;
    d[i] = d[i] % mod * f[i] % mod;
    b[i] = b[i] % mod * f[i] % mod;
  }
  fwtand(c, len);
  fwtand(d, len);
  fwtand(b, len);
  for (int i = 0; i <= len; i++) c[i] = c[i] * d[i] % mod * b[i] % mod;
  ifwtand(c, len);
  long long ans = 0;
  for (int i = 1; i <= len; i <<= 1) (ans += c[i] % mod) %= mod;
  std::cout << (ans + mod) % mod;
  return 0;
}