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 RenaMoe {
const int N = (1 << 17) + 5;
const int M = 1e6 + 5;
const int P = 1e9 + 7;
const int inv2 = (P + 1) >> 1;
inline void FWT_or(int *f, int n, int op) {
  for (int mid = 1; mid < n; mid <<= 1)
    for (int i = 0; i < n; i += mid << 1)
      for (int j = 0; j < mid; ++j) {
        if (op == 1)
          f[i + mid + j] += f[i + j];
        else
          f[i + mid + j] += P - f[i + j];
        f[i + mid + j] %= P;
      }
}
inline void FWT_and(int *f, int n, int op) {
  for (int mid = 1; mid < n; mid <<= 1)
    for (int i = 0; i < n; i += mid << 1)
      for (int j = 0; j < mid; ++j) {
        if (op == 1)
          f[i + j] += f[i + mid + j];
        else
          f[i + j] += P - f[i + mid + j];
        f[i + j] %= P;
      }
}
inline void FWT_xor(int *f, int n, int op) {
  for (int mid = 1; mid << 1 <= n; mid <<= 1)
    for (int i = 0; i < n; i += mid << 1)
      for (int j = 0; j < mid; ++j) {
        int x = f[i + j], y = f[i + mid + j];
        f[i + j] = (x + y) % P;
        f[i + mid + j] = (x - y + P) % P;
        if (op == -1) {
          f[i + j] = (long long)f[i + j] * inv2 % P;
          f[i + mid + j] = (long long)f[i + mid + j] * inv2 % P;
        }
      }
}
int sn, n;
int s[M], cnt[N], a[18][N], aa[18][N], b[N], f1[N], f2[N], f3[N], fib[N];
inline void main() {
  cin >> sn;
  for (int i = 1; i <= sn; ++i) cin >> s[i];
  n = 1 << 17;
  for (int i = 1; i < n; ++i) cnt[i] = cnt[i >> 1] + (i & 1);
  fib[1] = 1;
  for (int i = 2; i < n; ++i) fib[i] = (fib[i - 1] + fib[i - 2]) % P;
  for (int i = 1; i <= sn; ++i) ++a[cnt[s[i]]][s[i]];
  for (int i = 0; i <= 17; ++i) FWT_or(a[i], n, 1);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= 17; ++j)
      for (int k = 0; j + k <= 17; ++k)
        aa[j + k][i] = (aa[j + k][i] + (long long)a[j][i] * a[k][i]) % P;
  }
  for (int i = 0; i <= 17; ++i) FWT_or(aa[i], n, -1);
  for (int i = 0; i < n; ++i) f1[i] = (long long)fib[i] * aa[cnt[i]][i] % P;
  for (int i = 1; i <= sn; ++i) ++b[s[i]];
  for (int i = 0; i < n; ++i) f2[i] = (long long)fib[i] * b[i] % P;
  FWT_xor(b, n, 1);
  for (int i = 0; i < n; ++i) b[i] = (long long)b[i] * b[i] % P;
  FWT_xor(b, n, -1);
  for (int i = 0; i < n; ++i) f3[i] = (long long)fib[i] * b[i] % P;
  FWT_and(f1, n, 1), FWT_and(f2, n, 1), FWT_and(f3, n, 1);
  for (int i = 0; i < n; ++i) f1[i] = (long long)f1[i] * f2[i] % P * f3[i] % P;
  FWT_and(f1, n, -1);
  int ans = 0;
  for (int i = 0; i < 17; ++i) ans = (ans + f1[1 << i]) % P;
  cout << ans << endl;
}
}  // namespace RenaMoe
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  RenaMoe::main();
  cout.flush();
  return 0;
}