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 BL = 2 << 20;
struct streambufcin {
  std::streambuf *in;
  streambufcin() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    in = std::cin.rdbuf();
    bg = ed = NULL;
  }
  char buf[BL], *bg, *ed, ch;
  char gc() {
    return bg == ed ? ed = buf + in->sgetn(bg = buf, BL),
                      (bg == ed ? -1 : *bg++) : *bg++;
  }
  template <class T>
  streambufcin &operator>>(T &x) {
    bool neg = false;
    for (ch = gc(); !isdigit(ch); ch = gc())
      ;
    if (ch == '-') neg = true;
    for (x = 0; isdigit(ch); ch = gc()) x = x * 10 + ch - 48;
    if (neg) x = -x;
    return *this;
  }
  streambufcin &operator>>(char &c) {
    for (c = gc(); isspace(c); c = gc())
      ;
    return *this;
  }
} cin;
struct streambufcout {
  std::streambuf *out = std::cout.rdbuf();
  char buf[BL], *optr = buf;
  streambufcout() { out = std::cout.rdbuf(); }
  ~streambufcout() { flush(); }
  void flush() {
    out->sputn(buf, optr - buf);
    optr = buf;
  }
  void pc(char c) {
    if (optr == buf + BL) flush();
    *optr++ = c;
  }
  template <class T>
  streambufcout &operator<<(T x) {
    static int st[233], top;
    if (x < 0) {
      x = -x;
      pc('-');
    }
    do {
      st[++top] = x % 10;
      x /= 10;
    } while (x);
    while (top) pc(st[top--] ^ 48);
    return *this;
  }
  streambufcout &operator<<(char c) {
    pc(c);
    return *this;
  }
} cout;
int n;
const int N = 262144;
const int mod = 1e9 + 7;
const int inv2 = mod + 1 >> 1;
int s[N], fib[N], cnt[N];
int A[N], B[N], C[N], F[19][N], h[N], answer[N];
int add(int x, int y) {
  if (x + y >= mod)
    return x + y - mod;
  else
    return x + y;
}
int dec(int x, int y) {
  if (x - y < 0)
    return x - y + mod;
  else
    return x - y;
}
void mul(int &x, int y) { x = 1ll * x * y % mod; }
void _ad(int &x, int y) {
  x += y;
  if (x >= mod) x -= mod;
}
void _de(int &x, int y) {
  x -= y;
  if (x < 0) x += mod;
}
void FWTOR(int *f, int inv) {
  for (int len = 1; len < N; len <<= 1) {
    for (int i = 0; i < N; i += len << 1) {
      for (int j = 0; j < len; j++) {
        if (inv > 0)
          _ad(f[i + j + len], f[i + j]);
        else
          _de(f[i + j + len], f[i + j]);
      }
    }
  }
}
void FWTAND(int *f, int inv) {
  for (int len = 1; len < N; len <<= 1) {
    for (int i = 0; i < N; i += len << 1) {
      for (int j = 0; j < len; j++) {
        if (inv > 0)
          _ad(f[i + j], f[i + j + len]);
        else
          _de(f[i + j], f[i + j + len]);
      }
    }
  }
}
void FWTXOR(int *f, int inv) {
  for (int len = 1; len < N; len <<= 1) {
    for (int i = 0; i < N; i += len << 1) {
      for (int j = 0; j < len; j++) {
        int x = f[i + j], y = f[i + j + len];
        f[i + j] = add(x, y), f[i + j + len] = dec(x, y);
        if (inv < 0) mul(f[i + j], inv2), mul(f[i + j + len], inv2);
      }
    }
  }
}
int main() {
  for (int i = 1; i < 262144; i++) cnt[i] = cnt[i >> 1] + (i & 1);
  fib[0] = 0;
  fib[1] = 1;
  for (int i = 2; i < 262144; i++) fib[i] = add(fib[i - 1], fib[i - 2]);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    A[x]++;
    B[x]++;
    C[x]++;
  }
  for (int i = 0; i < 262144; i++) F[cnt[i]][i] = A[i], A[i] = 0;
  for (int i = 0; i < 19; i++) FWTOR(F[i], 1);
  for (int i = 0; i < 19; i++) {
    for (int j = 0; j < 262144; j++) h[j] = 0;
    for (int j = 0; j <= i; j++)
      for (int k = 0; k < 262144; k++)
        _ad(h[k], 1ll * F[j][k] * F[i - j][k] % mod);
    FWTOR(h, -1);
    for (int j = 0; j < 262144; j++)
      if (cnt[j] == i) A[j] = h[j];
  }
  FWTXOR(C, 1);
  for (int i = 0; i < 262144; i++) mul(C[i], C[i]);
  FWTXOR(C, -1);
  for (int i = 0; i < 262144; i++)
    mul(A[i], fib[i]), mul(B[i], fib[i]), mul(C[i], fib[i]);
  FWTAND(A, 1), FWTAND(B, 1), FWTAND(C, 1);
  for (int i = 0; i < 262144; i++)
    answer[i] = 1ll * A[i] * B[i] % mod * C[i] % mod;
  FWTAND(answer, -1);
  int Answer = 0;
  for (int i = 1; i < 262144; i <<= 1) _ad(Answer, answer[i]);
  cout << Answer << '\n';
  return 0;
}