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 dp[20][400011], g[20][400011], fib[1000011], f1[1000011], f2[1000011],
    f3[1000011], Ans[1000011], ans, hashh[1000011], n, maxx, bit, len;
long long a[1000011], cnt[1000011];
void FWT(long long *aa, long long type, long long op) {
  for (long long i = 2; i <= len; i <<= 1) {
    for (long long j = 0; j < len; j += i) {
      for (long long k = 0; k < (i >> 1); k++) {
        if (op == 1) {
          aa[j + k] = (aa[j + k] + aa[j + k + (i >> 1)] * type + 1000000007) %
                      1000000007;
        } else if (op == 2) {
          aa[j + k + (i >> 1)] =
              (aa[j + k + (i >> 1)] + aa[j + k] * type + 1000000007) %
              1000000007;
        } else {
          long long t1 = aa[j + k], t2 = aa[j + k + (i >> 1)];
          if (type == 1)
            aa[j + k] = (t1 + t2) % 1000000007,
                   aa[j + k + (i >> 1)] = (t1 - t2 + 1000000007) % 1000000007;
          else
            aa[j + k] = (t1 + t2) * 500000004 % 1000000007,
                   aa[j + k + (i >> 1)] =
                       (t1 - t2 + 1000000007) * 500000004 % 1000000007;
        }
      }
    }
  }
}
void init() {
  for (long long i = 1; i < len; i++) cnt[i] = cnt[i >> 1] + (i & 1);
  for (long long i = 1; i <= n; i++) g[cnt[a[i]]][a[i]]++;
  for (long long i = 0; i <= bit; i++) FWT(g[i], 1, 2);
  fib[0] = 0;
  fib[1] = 1;
  for (long long i = 2; i <= len; i++)
    fib[i] = (fib[i - 2] + fib[i - 1]) % 1000000007;
}
void solve1() {
  dp[0][0] = 0;
  FWT(dp[0], 1, 2);
  for (long long i = 1; i <= bit; i++) {
    for (long long j = 0; j <= i; j++) {
      for (long long k = 0; k < len; k++)
        dp[i][k] = (dp[i][k] + g[j][k] * g[i - j][k] % 1000000007) % 1000000007;
    }
    FWT(dp[i], -1, 2);
    for (long long j = 0; j < len; j++) {
      if (cnt[j] != i)
        dp[i][j] = 0;
      else
        f1[j] = dp[i][j];
    }
    FWT(dp[i], 1, 2);
  }
}
void solve2() {
  for (long long i = 0; i < len; i++) f2[i] = hashh[i];
}
void solve3() {
  for (long long i = 0; i < len; i++) f3[i] = hashh[i];
  FWT(f3, 1, 3);
  for (long long i = 0; i < len; i++) f3[i] = f3[i] * f3[i] % 1000000007;
  FWT(f3, -1, 3);
}
void solve() {
  for (long long i = 0; i < len; i++) {
    f1[i] = f1[i] * fib[i] % 1000000007;
    f2[i] = f2[i] * fib[i] % 1000000007;
    f3[i] = f3[i] * fib[i] % 1000000007;
  }
  FWT(f1, 1, 1);
  FWT(f2, 1, 1);
  FWT(f3, 1, 1);
  for (long long i = 0; i < len; i++)
    Ans[i] = f1[i] * f2[i] % 1000000007 * f3[i] % 1000000007;
  FWT(Ans, -1, 1);
  for (long long i = 1; i < len; i <<= 1) {
    ans = (ans + Ans[i]) % 1000000007;
  }
}
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++)
    scanf("%lld", &a[i]), maxx = max(maxx, a[i]);
  for (bit = 1;; bit++) {
    if ((1 << bit) > maxx) break;
  }
  len = (1 << bit);
  for (long long i = 1; i <= n; i++) hashh[a[i]]++;
  init();
  solve1();
  solve2();
  solve3();
  solve();
  printf("%lld\n", ans);
  return 0;
}