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;
long long read() {
  long long f = 1, x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -f;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + (s - '0');
    s = getchar();
  }
  return f * x;
}
char readchar() {
  char s = getchar();
  while (s == ' ' || s == '\n') s = getchar();
  return s;
}
const int MOD = 1000000007;
const int inv2 = 1000000008 / 2;
int n, m, i, j, s, o, k;
int qm(int a, int M) { return (a > M ? a - M : a); }
void DWTOR(int *s, int n) {
  for (int k = 1; k < n; k <<= 1) {
    for (int j = 0; j < n; j += (k << 1)) {
      for (int i = j; i < j + k; i++) {
        (s[i + k] += s[i]) %= MOD;
      }
    }
  }
  return;
}
void IDWTOR(int *s, int n) {
  for (int k = n / 2; k > 0; k >>= 1) {
    for (int j = 0; j < n; j += (k << 1)) {
      for (int i = j; i < j + k; i++) {
        (s[i + k] += MOD - s[i]) %= MOD;
      }
    }
  }
  return;
}
void DWTAND(int *s, int n) {
  for (int k = 1; k < n; k <<= 1) {
    for (int j = 0; j < n; j += (k << 1)) {
      for (int i = j; i < j + k; i++) {
        (s[i] += s[i + k]) %= MOD;
      }
    }
  }
  return;
}
void IDWTAND(int *s, int n) {
  for (int k = n / 2; k > 0; k >>= 1) {
    for (int j = 0; j < n; j += (k << 1)) {
      for (int i = j; i < j + k; i++) {
        (s[i] += MOD - s[i + k]) %= MOD;
      }
    }
  }
  return;
}
void DWTXOR(int *s, int n) {
  for (int k = 1; k < n; k <<= 1) {
    for (int j = 0; j < n; j += (k << 1)) {
      for (int i = j; i < j + k; i++) {
        int A = s[i], B = s[i + k];
        s[i] = qm((A + B), MOD);
        s[i + k] = qm((A + MOD - B), MOD);
      }
    }
  }
  return;
}
void IDWTXOR(int *s, int n) {
  for (int k = n / 2; k > 0; k >>= 1) {
    for (int j = 0; j < n; j += (k << 1)) {
      for (int i = j; i < j + k; i++) {
        int A = s[i], B = s[i + k];
        s[i] = qm((A + B), MOD) * 1ll * inv2 % MOD;
        s[i + k] = qm((A + MOD - B), MOD) * 1ll * inv2 % MOD;
      }
    }
  }
  return;
}
void putbit(int x, int bt) {
  if (bt == 0) return;
  putbit(x >> 1, bt - 1);
  putchar((x & 1) + '0');
}
int ct[(1 << 17 | 5)], po[(1 << 17 | 5)];
int A[21][(1 << 17 | 5)], B[21][(1 << 17 | 5)];
int aa[(1 << 17 | 5)], bb[(1 << 17 | 5)], cc[(1 << 17 | 5)];
int fi[(1 << 17 | 5)];
int main() {
  int le = read(), mn = 0;
  for (int i = 1; i < (1 << 17); i++) ct[i] = ct[i - (-(i) & (i))] + 1;
  for (int i = 1; i <= le; i++) {
    s = read();
    mn = max(mn, s);
    B[ct[s]][s]++;
    bb[s]++;
    cc[s]++;
  }
  n = 0, m = 1;
  while (m <= mn) m <<= 1, n++;
  for (int i = 0; i <= n; i++) DWTOR(B[i], m);
  DWTXOR(bb, m);
  for (int i = 0; i < m; i++) bb[i] = bb[i] * 1ll * bb[i] % MOD;
  IDWTXOR(bb, m);
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      for (int k = 0; k < m; k++) {
        (A[i][k] += B[j][k] * 1ll * B[i - j][k] % MOD) %= MOD;
      }
    }
    IDWTOR(A[i], m);
  }
  fi[0] = 0;
  fi[1] = 1;
  for (int i = 2; i < m; i++) fi[i] = (fi[i - 1] + fi[i - 2]) % MOD;
  for (int i = 0; i < m; i++) {
    aa[i] = A[ct[i]][i] * 1ll * fi[i] % MOD;
    bb[i] = bb[i] * 1ll * fi[i] % MOD;
    cc[i] = cc[i] * 1ll * fi[i] % MOD;
  }
  DWTAND(aa, m);
  DWTAND(bb, m);
  DWTAND(cc, m);
  for (int i = 0; i < m; i++) {
    aa[i] = aa[i] * 1ll * bb[i] % MOD * 1ll * cc[i] % MOD;
  }
  IDWTAND(aa, m);
  int ans = 0;
  for (int i = 1; i < m; i <<= 1) {
    (ans += aa[i]) %= MOD;
  }
  printf("%d\n", ans);
  return 0;
}