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;
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
const char lf = '\n';
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int ty() {
  int a = 0, b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
}  // namespace ae86
using ae86::ty;
const int _ = 131077, lglg = 18, mo = 1000000007;
long long powa(long long a, long long t) {
  long long b = 1;
  while (t) {
    if (t & 1) b = b * a % mo;
    a = a * a % mo, t >>= 1;
  }
  return b;
}
inline long long inva(long long a) { return powa(a, mo - 2); }
const long long inv2 = inva(2);
int fwtmake(int n) {
  int nn = 2;
  while (nn <= n) nn <<= 1;
  return nn;
}
void fwtor(long long a[], int nn, int dir) {
  for (int i = 1; i < nn; i <<= 1)
    for (int j = 0; j < nn; j += i + i)
      for (int k = 0; k < i; k++) {
        int x = a[j + k], y = a[j + k + i];
        if (dir > 0)
          a[j + k + i] = (x + y) % mo;
        else
          a[j + k + i] = (y - x + mo) % mo;
      }
}
void fwtand(long long a[], int nn, int dir) {
  for (int i = 1; i < nn; i <<= 1)
    for (int j = 0; j < nn; j += i + i)
      for (int k = 0; k < i; k++) {
        int x = a[j + k], y = a[j + k + i];
        if (dir > 0)
          a[j + k] = (x + y) % mo;
        else
          a[j + k] = (x - y + mo) % mo;
      }
}
void fwtxor(long long a[], int nn, int dir) {
  for (int i = 1; i < nn; i <<= 1)
    for (int j = 0; j < nn; j += i + i)
      for (int k = 0; k < i; k++) {
        int x = a[j + k], y = a[j + k + i];
        if (dir > 0)
          a[j + k] = (x + y) % mo, a[j + k + i] = (x - y + mo) % mo;
        else
          a[j + k] = (x + y) * inv2 % mo,
                a[j + k + i] = (x - y + mo) * inv2 % mo;
      }
}
long long fibna[_] = {0};
int bcnt[_] = {0};
void fuck(int n = _ - 1) {
  fibna[0] = 0, fibna[1] = 1;
  for (int i = 2; i <= n; i++) fibna[i] = (fibna[i - 1] + fibna[i - 2]) % mo;
  bcnt[0] = 0;
  for (int i = 1; i <= n; i++) bcnt[i] = bcnt[i >> 1] + (i & 1);
}
int n, mxval = 0;
long long cnt[_] = {0}, ans[_] = {0};
long long fab[_], fc[_], fde[_], temp[lglg + 1][_] = {0},
                                             temp2[lglg + 1][_] = {0};
int main() {
  ios::sync_with_stdio(0), cout.tie(nullptr);
  fuck();
  n = ty();
  for (int i = 1, a; i <= n; i++) a = ty(), mxval = max(mxval, a), cnt[a]++;
  int nn = fwtmake(mxval), dep = bcnt[nn - 1];
  for (int i = 0; i < nn; i++) fde[i] = cnt[i];
  fwtxor(fde, nn, 1);
  for (int i = 0; i < nn; i++) fde[i] = fde[i] * fde[i] % mo;
  fwtxor(fde, nn, -1);
  for (int i = 0; i < nn; i++) temp[bcnt[i]][i] = cnt[i];
  for (int i = 0; i <= dep; i++) fwtor(temp[i], nn, 1);
  for (int i = 0; i <= dep; i++)
    for (int j = 0; i + j <= dep; j++)
      for (int k = 0; k < nn; k++)
        temp2[i + j][k] = (temp2[i + j][k] + temp[i][k] * temp[j][k] % mo) % mo;
  for (int i = 0; i <= dep; i++) fwtor(temp2[i], nn, -1);
  for (int i = 0; i < nn; i++) fab[i] = temp2[bcnt[i]][i];
  for (int i = 0; i < nn; i++) fc[i] = cnt[i];
  for (int i = 0; i < nn; i++)
    fab[i] = fibna[i] * fab[i] % mo, fc[i] = fibna[i] * fc[i] % mo,
    fde[i] = fibna[i] * fde[i] % mo;
  fwtand(fab, nn, 1), fwtand(fc, nn, 1), fwtand(fde, nn, 1);
  for (int i = 0; i < nn; i++) ans[i] = fab[i] * fc[i] % mo * fde[i] % mo;
  fwtand(ans, nn, -1);
  long long sans = 0;
  for (int i = 0; i <= dep; i++) sans = (sans + ans[1 << i]) % mo;
  cout << sans << lf;
  return 0;
}