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, f[1000006], s[1000006], OR[1000006], SUB[1000006], XOR[1000006],
    AND[1000006], amount[1000006];
int p[18][1000006], q[18][1000006], l[18][1000006];
const int mod = 1e9 + 7, D = 17;
int power(long long a, int b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res % mod;
}
int inv2 = power(2, mod - 2);
int read() {
  char c = getchar();
  int x = 0;
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  return x;
}
void build() {
  f[1] = 1;
  int limit = (1 << D) - 1;
  for (int i = 2; i <= limit; ++i) f[i] = (f[i - 1] + f[i - 2]) % mod;
  for (int i = 1; i <= limit; ++i) amount[i] = amount[i >> 1] + (i & 1);
}
int init(int n) {
  int limit = 1;
  while (limit <= n) limit <<= 1;
  return limit;
}
void FWTAND(int* a, int n, int opt) {
  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 (opt == 1)
          a[j + k] = (x + y) % mod;
        else
          a[j + k] = (x - y) % mod;
      }
}
void FWTOR(int* a, int n, int opt) {
  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 (opt == 1)
          a[j + k + i] = (x + y) % mod;
        else
          a[j + k + i] = (y - x + mod) % mod;
      }
}
void FWTXOR(int* a, int n, int opt) {
  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 (opt == 1) {
          a[j + k] = (x + y) % mod;
          a[j + k + i] = (x - y + mod) % mod;
        } else {
          a[j + k] = 1ll * (x + y) * inv2 % mod;
          a[j + k + i] = 1ll * (x - y + mod) * inv2 % mod;
        }
      }
}
void FST(int* a, int n, int opt) {
  for (int i = 0; i < D; ++i)
    for (int j = 0; j < n; ++j)
      if (j >> i & 1) {
        if (opt == 1)
          a[j] = (a[j] + a[j ^ (1 << i)]) % mod;
        else
          a[j] = (a[j] - a[j ^ (1 << i)] + mod) % mod;
      }
}
int main() {
  n = read();
  build();
  int maxi = 0;
  for (int i = 1; i <= n; ++i) {
    s[i] = read();
    maxi = max(maxi, s[i]);
    ++OR[s[i]];
    ++XOR[s[i]];
    ++AND[s[i]];
  }
  int m = init(maxi);
  for (int i = 0; i < m; ++i) p[amount[i]][i] = OR[i];
  for (int i = 0; i < D; ++i) FST(p[i], m, 1);
  for (int i = 0; i <= D; ++i)
    for (int j = 0; j <= i; ++j)
      for (int s = 0; s < m; ++s)
        q[i][s] = (1ll * p[i - j][s] * p[j][s] % mod + q[i][s]) % mod;
  for (int i = 0; i <= D; ++i) FST(q[i], m, -1);
  for (int i = 0; i < m; ++i) OR[i] = q[amount[i]][i];
  FWTXOR(XOR, m, 1);
  for (int i = 0; i < m; ++i) XOR[i] = 1ll * XOR[i] * XOR[i] % mod;
  FWTXOR(XOR, m, -1);
  for (int i = 1; i <= m; ++i) OR[i] = 1ll * f[i] * OR[i] % mod;
  for (int i = 1; i <= m; ++i) XOR[i] = 1ll * f[i] * XOR[i] % mod;
  for (int i = 1; i <= m; ++i) AND[i] = 1ll * f[i] * AND[i] % mod;
  FWTAND(AND, m, 1);
  FWTAND(OR, m, 1);
  FWTAND(XOR, m, 1);
  for (int i = 0; i < m; ++i)
    AND[i] = 1ll * AND[i] * XOR[i] % mod * OR[i] % mod;
  FWTAND(AND, m, -1);
  int ans = 0;
  for (int i = 0; i < D; ++i) ans = (ans + AND[(1 << i)]) % mod;
  printf("%d\n", (ans + mod) % mod);
}