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 = (1 << 17) + 5;
const long long inv2 = (1 + 1000000007) / 2;
void fwtor(long long *a, int n, int o) {
  for (int len = 2; len <= n; len <<= 1)
    for (int j = 0; j < n; j += len)
      for (int k = j; k < j + (len >> 1); k++)
        a[k + (len >> 1)] =
            (a[k + (len >> 1)] + o * a[k] + 1000000007) % 1000000007;
}
void fwtand(long long *a, int n, int o) {
  for (int len = 2; len <= n; len <<= 1)
    for (int j = 0; j < n; j += len)
      for (int k = j; k < j + (len >> 1); k++)
        a[k] = (a[k] + o * a[k + (len >> 1)] + 1000000007) % 1000000007;
}
void fwtxor(long long *a, int n, int o) {
  for (int len = 2; len <= n; len <<= 1)
    for (int j = 0; j < n; j += len)
      for (int k = j; k < j + (len >> 1); k++) {
        long long X = a[k], Y = a[k + (len >> 1)];
        a[k] = (X + Y) % 1000000007,
        a[k + (len >> 1)] = (X - Y + 1000000007) % 1000000007;
        if (o == -1)
          a[k] = a[k] * inv2 % 1000000007,
          a[k + (len >> 1)] = a[k + (len >> 1)] * inv2 % 1000000007;
      }
}
int n, fib[N], cnt[N];
long long f[19][N], a[N], b[N], c[N], ls[N];
void init() {
  fib[1] = 1;
  for (int i = 2; i < N; i++) fib[i] = (fib[i - 1] + fib[i - 2]) % 1000000007;
  for (int i = 1; i < N; i++) cnt[i] = cnt[i >> 1] + (i & 1);
}
void FST(int n) {
  for (int i = 0; i <= 17; i++) fwtor(f[i], n, 1);
  for (int i = 0; i <= 17; i++) {
    for (int S = 0; S < n; S++) ls[S] = 0;
    for (int j = 0; j <= i; j++)
      for (int S = 0; S < n; S++)
        ls[S] = (ls[S] + f[j][S] * f[i - j][S] % 1000000007) % 1000000007;
    fwtor(ls, n, -1);
    for (int S = 0; S < n; S++)
      if (cnt[S] == i) a[S] = (a[S] + ls[S]) % 1000000007;
  }
}
int main() {
  init();
  scanf("%d", &n);
  for (int i = 1, x; i <= n; i++) {
    scanf("%d", &x);
    f[cnt[x]][x]++, b[x] = (b[x] + fib[x]) % 1000000007, c[x]++;
  }
  int len = (1 << 17);
  FST(len);
  fwtxor(c, len, 1);
  for (int i = 0; i < len; i++) c[i] = c[i] * c[i] % 1000000007;
  fwtxor(c, len, -1);
  for (int i = 0; i < len; i++)
    a[i] = a[i] * fib[i] % 1000000007, c[i] = c[i] * fib[i] % 1000000007;
  fwtand(a, len, 1), fwtand(b, len, 1), fwtand(c, len, 1);
  for (int i = 0; i < len; i++)
    a[i] = a[i] * b[i] % 1000000007 * c[i] % 1000000007;
  fwtand(a, len, -1);
  long long ans = 0;
  for (int i = 1; i < len; i <<= 1) ans = (ans + a[i]) % 1000000007;
  printf("%lld", ans);
  return 0;
}