Problem: Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 < i2 < ... < ik ≤ n) a group of size k. 

Jzzhu wonders, how many groups exists such that ai1 & ai2 & ... & aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). Operation x & y denotes bitwise AND operation of two numbers.

Input

The first line contains a single integer n (1 ≤ n ≤ 106). The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 106).

Output

Output a single integer representing the number of required groups modulo 1000000007 (109 + 7).

Examples

Input

3
2 3 3


Output

0


Input

4
0 1 2 3


Output

10


Input

6
5 2 0 5 2 1


Output

53

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
long long mpow(long long x, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n /= 2;
  }
  return res;
}
long long inv(long long x) { return mpow(x, mod - 2); }
int main() {
  vector<long long> fac(10000, 1);
  vector<long long> invfac(10000, 1);
  for (int i = 2; i < fac.size(); ++i) {
    fac[i] = fac[i - 1] * i % mod;
    invfac[i] = inv(fac[i]);
  }
  vector<long long> pw2(1000001, 1);
  for (int i = 1; i < pw2.size(); ++i) pw2[i] = pw2[i - 1] * 2 % mod;
  int n;
  cin >> n;
  vector<int> a(n);
  vector<vector<long long> > v(1000001, vector<long long>(21));
  for (int i = 0; i < a.size(); ++i) {
    scanf("%d", &a[i]);
    ++v[a[i]][0];
  }
  long long res = 0;
  for (int i = v.size() - 1; i >= 0; --i) {
    long long tot = v[i][0];
    int maxind = 0;
    for (int h = 1; h < v[i].size(); ++h)
      if (v[i][h]) {
        v[i][h] %= mod;
        tot = (tot + v[i][h] * invfac[h]) % mod;
        maxind = h;
      }
    maxind = min(maxind, (int)v[i].size() - 2);
    int cnt = 0;
    for (int b = 0; b < 20; ++b)
      if (i & (1 << b)) {
        ++cnt;
        int j = (i ^ (1 << b));
        for (int h = 0; h <= maxind; ++h) v[j][h + 1] += v[i][h];
      }
    res = (res + ((cnt % 2) ? -1 : 1) * (pw2[tot] - 1)) % mod;
  }
  cout << (res % mod + mod) % mod << endl;
  return 0;
}