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>
const int inv2 = 1000000007 + 1 >> 1;
using namespace std;
int n, s[1000005], ct[131072 + 1], ctor[18][131072 + 1], ctxor[131072 + 1],
    f[131072 + 1], ctsub[18][131072 + 1];
int Ctor[131072 + 1], f1[131072 + 1], f2[131072 + 1], f3[131072 + 1];
void fwtor(int* a, int f) {
  for (int i = 1; i < 131072; i <<= 1)
    for (int j = 0; j < 131072; j += i << 1)
      for (int k = 0; k < i; ++k) {
        int x = a[j + k], y = a[j + k + i];
        if (f)
          a[j + k + i] = (x + y) % 1000000007;
        else
          a[j + k + i] = (y - x + 1000000007) % 1000000007;
      }
}
void fwtxor(int* a, int f) {
  for (int i = 1; i < 131072; i <<= 1)
    for (int j = 0; j < 131072; j += i << 1)
      for (int k = 0; k < i; ++k) {
        int x = a[j + k], y = a[j + k + i];
        a[j + k] = (x + y) % 1000000007;
        a[j + k + i] = (x - y + 1000000007) % 1000000007;
        if (!f)
          a[j + k] = 1ll * a[j + k] * inv2 % 1000000007,
                a[j + k + i] = 1ll * a[j + k + i] * inv2 % 1000000007;
      }
}
void fwtand(int* a, int f) {
  for (int i = 1; i < 131072; i <<= 1)
    for (int j = 0; j < 131072; j += i << 1)
      for (int k = 0; k < i; ++k) {
        int x = a[j + k], y = a[j + k + i];
        if (f)
          a[j + k] = (x + y) % 1000000007;
        else
          a[j + k] = (x - y + 1000000007) % 1000000007;
      }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++ct[s[i++]]) cin >> s[i];
  for (int i = 0; i < 131072; ++i) ctor[__builtin_popcount(i)][i] = ct[i];
  for (int i = 0; i < 18; ++i) fwtor(ctor[i], 1);
  for (int i = 0; i < 18; ++i) {
    for (int j = 0; j <= i; ++j)
      for (int k = 0; k < 131072; ++k)
        ctsub[i][k] =
            (ctsub[i][k] + 1ll * ctor[j][k] * ctor[i - j][k]) % 1000000007;
    fwtor(ctsub[i], 0);
  }
  for (int i = 0; i < 131072; ++i) Ctor[i] = ctsub[__builtin_popcount(i)][i];
  memcpy(ctxor, ct, sizeof ct);
  fwtxor(ctxor, 1);
  for (int i = 0; i < 131072; ++i)
    ctxor[i] = 1ll * ctxor[i] * ctxor[i] % 1000000007;
  fwtxor(ctxor, 0);
  f[1] = 1;
  for (int i = 2; i <= 131072; ++i) f[i] = (f[i - 1] + f[i - 2]) % 1000000007;
  for (int i = 0; i < 131072; ++i) {
    f1[i] = Ctor[i] * 1ll * f[i] % 1000000007;
    f2[i] = ct[i] * 1ll * f[i] % 1000000007;
    f3[i] = ctxor[i] * 1ll * f[i] % 1000000007;
  }
  fwtand(f1, 1), fwtand(f2, 1), fwtand(f3, 1);
  for (int i = 0; i < 131072; ++i)
    f1[i] = 1ll * f1[i] * f2[i] % 1000000007 * f3[i] % 1000000007;
  fwtand(f1, 0);
  int ans = 0;
  for (int i = 0; i < 18; ++i) ans = (ans + f1[1 << i]) % 1000000007;
  cout << ans << '\n';
  return 0;
}