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;
int n, N, i, j, k, a[131072], b[131072], c[131072], d[131072][18], e[131072],
    f[131072], g[18], ans;
int main() {
  N = 131072;
  scanf("%d", &n);
  for (i = 1; i < N; i++) e[i] = e[i >> 1] + (i & 1);
  for (f[1] = 1, i = 2; i < N; i++) {
    f[i] = f[i - 1] + f[i - 2];
    if (f[i] >= 1000000007) f[i] -= 1000000007;
  }
  while (n--) {
    scanf("%d", &i);
    d[i][e[i]]++;
    b[i]++;
    c[i]++;
  }
  n = 17;
  for (i = 0; i < n; i++)
    for (j = 0; j < N; j++)
      if (j >> i & 1) {
        k = c[j] + c[j ^ (1 << i)];
        c[j] = c[j ^ (1 << i)] - c[j];
        c[j ^ (1 << i)] = k;
        if (c[j] < 0) c[j] += 1000000007;
        if (c[j ^ (1 << i)] >= 1000000007) c[j ^ (1 << i)] -= 1000000007;
        for (k = 0; k <= n; k++) {
          d[j][k] += d[j ^ (1 << i)][k];
          if (d[j][k] >= 1000000007) d[j][k] -= 1000000007;
        }
      }
  for (i = 0; i < N; i++) {
    c[i] = (long long)c[i] * c[i] % 1000000007;
    memset(g, 0, sizeof(g));
    for (j = 0; j <= n; j++)
      for (k = 0; k <= n; k++)
        if (j + k <= n)
          g[j + k] = (g[j + k] + (long long)d[i][j] * d[i][k]) % 1000000007;
    for (j = 0; j <= n; j++) d[i][j] = g[j];
  }
  for (i = 0; i < n; i++)
    for (j = 0; j < N; j++)
      if (j >> i & 1) {
        k = c[j] + c[j ^ (1 << i)];
        c[j] = c[j ^ (1 << i)] - c[j];
        c[j ^ (1 << i)] = k;
        if (c[j] < 0) c[j] += 1000000007;
        if (c[j ^ (1 << i)] >= 1000000007) c[j ^ (1 << i)] -= 1000000007;
        for (k = 0; k <= n; k++) {
          d[j][k] -= d[j ^ (1 << i)][k];
          if (d[j][k] < 0) d[j][k] += 1000000007;
        }
      }
  for (i = 0; i < N; i++) {
    a[i] = (long long)d[i][e[i]] * f[i] % 1000000007;
    b[i] = (long long)b[i] * f[i] % 1000000007;
    c[i] = (long long)c[i] * f[i] % 1000000007 * 742744451 % 1000000007;
  }
  for (i = 0; i < n; i++)
    for (j = 0; j < N; j++)
      if (j >> i & 1) {
        a[j ^ (1 << i)] += a[j];
        b[j ^ (1 << i)] += b[j];
        c[j ^ (1 << i)] += c[j];
        if (a[j ^ (1 << i)] >= 1000000007) a[j ^ (1 << i)] -= 1000000007;
        if (b[j ^ (1 << i)] >= 1000000007) b[j ^ (1 << i)] -= 1000000007;
        if (c[j ^ (1 << i)] >= 1000000007) c[j ^ (1 << i)] -= 1000000007;
      }
  for (i = 0; i < N; i++)
    a[i] = (long long)a[i] * b[i] % 1000000007 * c[i] % 1000000007;
  for (i = 0; i < n; i++)
    for (j = 0; j < N; j++)
      if (j >> i & 1) {
        a[j ^ (1 << i)] -= a[j];
        if (a[j ^ (1 << i)] < 0) a[j ^ (1 << i)] += 1000000007;
      }
  for (i = 0; i < n; i++) {
    ans += a[1 << i];
    if (ans >= 1000000007) ans -= 1000000007;
  }
  cout << ans << endl;
  return 0;
}