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 = 140005, mod = 1000000007, inv2 = 500000004;
int n, m, k, ans, a[N], b[N], c[N], fib[N], tot[N], f1[20][N], f2[20][N];
void fwt(int *a, int md) {
  for (int i = 1; i < m; i <<= 1) {
    for (int j = 0; j < m; j += (i << 1)) {
      int x, y;
      if (md > 0) {
        for (int k = j; k < j + i; k++) {
          x = a[k];
          y = a[k + i];
          if (md == 1) {
            a[k] = x + y < mod ? x + y : x + y - mod;
          } else if (md == 2) {
            a[k + i] = x + y < mod ? x + y : x + y - mod;
          } else {
            a[k] = x + y < mod ? x + y : x + y - mod;
            a[k + i] = x - y >= 0 ? x - y : x - y + mod;
          }
        }
      } else {
        for (int k = j; k < j + i; k++) {
          x = a[k];
          y = a[k + i];
          if (md == -1) {
            a[k] = x - y >= 0 ? x - y : x - y + mod;
          } else if (md == -2) {
            a[k + i] = y - x >= 0 ? y - x : y - x + mod;
          } else {
            a[k] = x + y < mod ? x + y : x + y - mod;
            a[k + i] = x - y >= 0 ? x - y : x - y + mod;
            a[k] = 1LL * a[k] * inv2 % mod;
            a[k + i] = 1LL * a[k + i] * inv2 % mod;
          }
        }
      }
    }
  }
}
void fst(int *a) {
  for (int i = 0; i < m; i++) {
    f1[tot[i]][i] = a[i];
  }
  for (int i = 0; i <= k; i++) {
    fwt(f1[i], 2);
  }
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= i; j++) {
      for (int k = 0; k < m; k++) {
        f2[i][k] += 1LL * f1[j][k] * f1[i - j][k] % mod;
        f2[i][k] %= mod;
      }
    }
  }
  for (int i = 0; i <= k; i++) {
    fwt(f2[i], -2);
  }
  for (int i = 0; i < m; i++) {
    a[i] = f2[tot[i]][i];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &m);
    a[m]++;
    b[m]++;
    c[m]++;
  }
  k = 17;
  m = 131072;
  for (int i = 0; i < m; i++) {
    for (int j = 0; (1 << j) <= i; j++) {
      if (i & (1 << j)) {
        tot[i]++;
      }
    }
  }
  fib[0] = 0, fib[1] = 1;
  for (int i = 2; i < m; i++) {
    fib[i] = (fib[i - 2] + fib[i - 1]) % mod;
  }
  fst(a);
  fwt(c, 3);
  for (int i = 0; i < m; i++) {
    c[i] = 1LL * c[i] * c[i] % mod;
  }
  fwt(c, -3);
  for (int i = 0; i < m; i++) {
    a[i] = 1LL * a[i] * fib[i] % mod;
    b[i] = 1LL * b[i] * fib[i] % mod;
    c[i] = 1LL * c[i] * fib[i] % mod;
  }
  fwt(a, 1);
  fwt(b, 1);
  fwt(c, 1);
  for (int i = 0; i < m; i++) {
    a[i] = 1LL * a[i] * b[i] % mod * c[i] % mod;
  }
  fwt(a, -1);
  for (int i = 0; i < k; i++) {
    ans += a[1 << i];
    ans %= mod;
  }
  printf("%d\n", ans);
  return 0;
}