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;
namespace Final {
int f[1 << 17 | 1], g[1 << 17 | 1], h[1 << 17 | 1];
}
int c[17 + 1][1 << 17 | 1], v[17 + 1][1 << 17 | 1];
int f[1 << 17 | 1], g[1 << 17 | 1];
int k[1 << 17 | 1];
void FWT(int *f, int n, int w) {
  int i, j, l;
  int k;
  for (l = 0; (1 << l) < n; l++)
    for (i = 0; i < n; i += 1 << (l + 1))
      for (j = 0; j < (1 << l); j++)
        if (w == 1 || w == -1)
          f[i + j] = (f[i + j] + w * f[i + j + (1 << l)]) % 1000000007;
        else if (w == 2 || w == -2)
          f[i + j + (1 << l)] =
              (f[i + j + (1 << l)] + (w < 0 ? -1 : 1) * f[i + j]) % 1000000007;
        else {
          k = f[i + j];
          f[i + j] = (f[i + j] + f[i + j + (1 << l)]) % 1000000007;
          f[i + j + (1 << l)] = (k - f[i + j + (1 << l)]) % 1000000007;
          if (w < 0) {
            f[i + j] = (long long)f[i + j] * 500000004 % 1000000007;
            f[i + j + (1 << l)] =
                (long long)f[i + j + (1 << l)] * 500000004 % 1000000007;
          }
        }
  return;
}
int main(void) {
  int n, x;
  int i, j, t;
  for (i = 1; i < (1 << 17); i++) k[i] = k[i & (i - 1)] + 1;
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &x);
    c[k[x]][x]++;
  }
  for (i = 2, f[1] = 1; i < (1 << 17); i++)
    f[i] = (f[i - 1] + f[i - 2]) % 1000000007;
  for (i = 0; i < (1 << 17); i++) {
    g[i] = c[k[i]][i];
    Final::g[i] = (long long)c[k[i]][i] * f[i] % 1000000007;
  }
  FWT(g, 1 << 17, 3);
  for (i = 0; i < (1 << 17); i++) g[i] = (long long)g[i] * g[i] % 1000000007;
  FWT(g, 1 << 17, -3);
  for (i = 0; i < (1 << 17); i++)
    Final::h[i] = (long long)g[i] * f[i] % 1000000007;
  for (i = 0; i <= 17; i++) FWT(c[i], 1 << 17, 2);
  for (i = 1; i <= 17; i++)
    for (j = 0; j <= i; j++)
      for (t = 0; t < (1 << 17); t++)
        v[i][t] = (v[i][t] + (long long)c[j][t] * c[i - j][t] % 1000000007) %
                  1000000007;
  for (i = 0; i <= 17; i++) FWT(v[i], 1 << 17, -2);
  for (i = 0; i < (1 << 17); i++)
    Final::f[i] = (long long)v[k[i]][i] * f[i] % 1000000007;
  FWT(Final::f, 1 << 17, 1);
  FWT(Final::g, 1 << 17, 1);
  FWT(Final::h, 1 << 17, 1);
  for (i = 0; i < (1 << 17); i++)
    Final::f[i] = (long long)Final::f[i] * Final::g[i] % 1000000007 *
                  Final::h[i] % 1000000007;
  FWT(Final::f, 1 << 17, -1);
  for (i = t = 0; i < 17; i++) t = (t + Final::f[1 << i]) % 1000000007;
  printf("%d\n", (t + 1000000007) % 1000000007);
  return 0;
}