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 = 1000010, P = 1e9 + 7, MX = 1 << 17, inv2 = P + 1 >> 1;
int n, a[N], f[N], g[N], b[N], fb[N];
inline void FMT(int *a, int n) {
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < MX; j++)
      if (j & i)
        ;
      else
        a[j | i] = (a[j | i] + a[j]) % P;
}
inline void iFMT(int *a, int n) {
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < MX; j++)
      if (j & i)
        ;
      else
        a[j | i] = (a[j | i] + P - a[j]) % P;
}
inline void FWT(int *a, int n, int r) {
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < n; j += (i << 1))
      for (int k = 0; k < i; k++) {
        int x = a[j + k], y = a[j + k + i];
        if (r)
          a[j + k] = (x + y) % P, a[j + k + i] = (x + P - y) % P;
        else
          a[j + k] = 1LL * (x + y) * inv2 % P,
                a[j + k + i] = 1LL * (x + P - y) * inv2 % P;
      }
}
int main() {
  scanf("%d", &n);
  for (int i = 1, x; i <= n; i++) scanf("%d", &x), a[x]++;
  fb[1] = 1;
  for (int i = 2; i < MX; i++) fb[i] = (fb[i - 1] + fb[i - 2]) % P;
  for (int i = 0; i < MX; i++)
    f[i] = a[i], b[i] = 1LL * a[(MX - 1) ^ i] * fb[(MX - 1) ^ i] % P;
  for (int i = 1; i < MX; i++)
    for (int j = i;; j = (j - 1) & i) {
      g[i] = (g[i] + 1LL * f[j] * f[i ^ j]) % P;
      if (!j) break;
    }
  for (int i = 0; i < MX; i++) f[i] = 1LL * g[i] * fb[i] % P;
  for (int i = 0; i < MX; i++) g[i] = f[(MX - 1) ^ i];
  FMT(g, MX);
  FMT(b, MX);
  for (int i = 0; i < MX; i++) b[i] = 1LL * g[i] * b[i] % P;
  iFMT(b, MX);
  for (int i = 0; i < MX; i++) g[i] = b[i];
  for (int i = 0; i < MX; i++) b[i] = a[i];
  FWT(b, MX, 1);
  for (int i = 0; i < MX; i++) b[i] = 1LL * b[i] * b[i] % P;
  FWT(b, MX, 0);
  for (int i = 0; i < MX; i++) b[i] = 1LL * b[i] * fb[i] % P;
  reverse(b, b + MX);
  FMT(g, MX);
  FMT(b, MX);
  for (int i = 0; i < MX; i++) g[i] = 1LL * g[i] * b[i] % P;
  iFMT(g, MX);
  reverse(g, g + MX);
  int ans = 0;
  for (int i = 1; i < MX; i <<= 1) ans = (ans + g[i]) % P;
  printf("%d\n", ans);
  return 0;
}