2
1 31
 2
1 0
 10
450661 128600 993228 725823 293549 33490 843121 903634 556169 448234
 1
1
 5
1 3 5 7 9
 6
524 529 5249 524 529 529
 3
1 2 3
 2
0 1
 55
0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 3 4 5 6 7 8 9 4 5 6 7 8 9 5 6 7 8 9 6 7 8 9 7 8 9 8 9 9
 16
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
 3
128 1024 2048
 10
3 3 3 5 5 3 3 3 3 5
 1
0
 2
1 2
 2
0 0
 2
1 1

0
 2
 632
 0
 0
 24
 2
 2
 621247139
 64594
 4
 0
 1
 1
 3
 0

#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;
}
