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;
int fib[1000010];
int s[1000010];
void FWT_xor(int f[], int l, int type) {
  for (int i = 2; i <= l; i = i << 1) {
    for (int j = 0; j < l; j += i) {
      for (int k = j; k < j + i / 2; ++k) {
        int u = f[k], t = f[k + i / 2];
        f[k] = (u + t) % 1000000007;
        f[k + i / 2] = (u - t + 1000000007) % 1000000007;
        if (type == -1) {
          f[k] = 1ll * f[k] * 500000004 % 1000000007;
          f[k + i / 2] = 1ll * f[k + i / 2] * 500000004 % 1000000007;
        }
      }
    }
  }
  return;
}
void FWT_and(int f[], int l, int type) {
  for (int i = 2; i <= l; i = i << 1)
    for (int j = 0; j < l; j += i)
      for (int k = j; k < j + i / 2; ++k)
        f[k] = (f[k] + 1ll * (1000000007 + type) * f[k + i / 2] % 1000000007) %
               1000000007;
  return;
}
void FWT_or(int f[], int l, int type) {
  for (int i = 2; i <= l; i = i << 1)
    for (int j = 0; j < l; j += i)
      for (int k = j; k < j + i / 2; ++k)
        f[k + i / 2] =
            (f[k + i / 2] + 1ll * (1000000007 + type) * f[k] % 1000000007) %
            1000000007;
  return;
}
int bit[1000010];
int cnt[1000010], cnt2[1000010], cnt3[1000010];
int f[18][1000010], g[18][1000010];
void calc1(int cnt[], int cnt2[], int len) {
  for (int i = 0; i < len; ++i) f[bit[i]][i] = cnt[i];
  for (int i = 0; i <= 17; ++i) FWT_or(f[i], len, 1);
  for (int i = 0; i <= 17; ++i)
    for (int j = 0; j <= i; ++j)
      for (int s = 0; s < len; ++s)
        g[i][s] =
            (g[i][s] + 1ll * f[j][s] * f[i - j][s] % 1000000007) % 1000000007;
  for (int i = 0; i <= 17; ++i) FWT_or(g[i], len, -1);
  for (int s = 0; s < len; ++s)
    cnt2[s] = 1ll * g[bit[s]][s] * fib[s] % 1000000007;
  return;
}
int ans[1000010];
int main() {
  scanf("%d", &n);
  int mx = 0;
  for (int i = 1; i <= n; ++i) scanf("%d", &s[i]);
  for (int i = 1; i <= n; ++i) mx = max(mx, s[i]);
  int len = 1;
  for (; len <= mx; len = len << 1)
    ;
  for (int i = 1; i < len; ++i) bit[i] = bit[i ^ (i & (-i))] + 1;
  fib[0] = 0;
  fib[1] = 1;
  for (int i = 2; i < 200000; ++i)
    fib[i] = (fib[i - 1] + fib[i - 2]) % 1000000007;
  for (int i = 1; i <= n; ++i) ++cnt[s[i]];
  calc1(cnt, cnt2, len);
  FWT_xor(cnt, len, 1);
  for (int i = 0; i < len; ++i) cnt3[i] = 1ll * cnt[i] * cnt[i] % 1000000007;
  FWT_xor(cnt, len, -1);
  FWT_xor(cnt3, len, -1);
  for (int i = 0; i < len; ++i) cnt3[i] = 1ll * cnt3[i] * fib[i] % 1000000007;
  for (int i = 0; i < len; ++i) cnt[i] = 1ll * cnt[i] * fib[i] % 1000000007;
  FWT_and(cnt, len, 1);
  FWT_and(cnt2, len, 1);
  FWT_and(cnt3, len, 1);
  for (int i = 0; i < len; ++i)
    ans[i] = 1ll * cnt[i] * cnt2[i] % 1000000007 * cnt3[i] % 1000000007;
  FWT_and(ans, len, -1);
  int cur = 1, res = 0;
  while (cur < len) res = (res + ans[cur]) % 1000000007, cur = cur << 1;
  cout << res << endl;
  return 0;
}