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 N = 1 << 18, mu = 1e9 + 7, inv2 = (mu + 1) >> 1;
int a[N], p[N], f[N], b[N], c[N], t[18][N], l, limit = 1, mx, n, s[1000005],
                                               cnt[18][N];
void reduce(int &x) { x += x >> 31 & mu; }
void fwt_or(int *a, int opt) {
  for (int mid = 1; mid < limit; mid <<= 1)
    for (int r = mid << 1, i = 0; i < limit; i += r)
      for (int j = 0; j < mid; j++)
        if (opt == 1)
          reduce(a[i + j + mid] += a[i + j] - mu);
        else
          reduce(a[i + j + mid] -= a[i + j]);
}
void fwt_xor(int *a, int opt) {
  for (int mid = 1; mid < limit; mid <<= 1)
    for (int r = mid << 1, i = 0; i < limit; i += r)
      for (int j = 0; j < mid; j++) {
        int x = a[i + j], y = a[i + j + mid];
        reduce(a[i + j] = x + y - mu);
        reduce(a[i + j + mid] = x - y);
        if (opt == -1)
          a[i + j] = a[i + j] * 1ll * inv2 % mu,
                a[i + j + mid] = a[i + j + mid] * 1ll * inv2 % mu;
      }
}
void fwt_and(int *a, int opt) {
  for (int mid = 1; mid < limit; mid <<= 1)
    for (int r = mid << 1, i = 0; i < limit; i += r)
      for (int j = 0; j < mid; j++)
        if (opt == 1)
          reduce(a[i + j] += a[i + j + mid] - mu);
        else
          reduce(a[i + j] -= a[i + j + mid]);
}
void init() {
  limit = 1;
  while (limit <= mx) limit <<= 1, l++;
  for (int i = 2; i <= limit; i++) p[i] = p[i >> 1] + (i & 1);
  f[0] = 0, f[1] = 1;
  for (int i = 2; i <= limit; i++) reduce(f[i] = f[i - 1] + f[i - 2] - mu);
  for (int i = 1; i <= n; i++) {
    cnt[p[s[i]]][s[i]]++;
    reduce(b[s[i]] += f[s[i]] - mu);
    c[s[i]]++;
  }
}
void fst() {
  for (int i = 0; i <= l; i++) fwt_or(cnt[i], 1);
  for (int i = 0; i <= l; i++) {
    for (int j = 0; j <= i; j++)
      for (int S = 0; S < limit; S++)
        t[i][S] = (t[i][S] + cnt[j][S] * 1ll * cnt[i - j][S]) % mu;
    fwt_or(t[i], -1);
  }
  for (int i = 0; i < limit; i++) a[i] = t[p[i]][i] * 1ll * f[i] % mu;
}
int main() {
  scanf("%d", &n);
  p[1] = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &s[i]);
    mx = std::max(mx, s[i]);
  }
  init();
  fst();
  fwt_xor(c, 1);
  for (int i = 0; i < limit; i++) c[i] = c[i] * 1ll * c[i] % mu;
  fwt_xor(c, -1);
  for (int i = 0; i < limit; i++) c[i] = c[i] * 1ll * f[i] % mu;
  fwt_and(a, 1), fwt_and(b, 1), fwt_and(c, 1);
  for (int i = 0; i < limit; i++) a[i] = 1ll * a[i] * b[i] % mu * c[i] % mu;
  fwt_and(a, -1);
  int ans = 0;
  for (int i = 1; i < limit; i <<= 1) reduce(ans += a[i] - mu);
  printf("%d\n", ans);
}