Zero AND Subsets

Given a multiset of nonnegative integers a_1, a_2, .., a_N.

How many non-empty subsets of this set have a value bitwiseAND of 0?

Find the remainder of the answer divided by 10 ^ 9 + 7.

input


N
a_1 a_2 ... a_N


output

Divide the answer by 10 ^ 9 + 7 and output the remainder.

Constraint

* 1 \ leq N \ leq 10 ^ 5
* 0 \ leq a_i \ leq 2 ^ {20} -1



Input example


6
8 6 9 1 2 1


Output example


51






Example

Input

6
8 6 9 1 2 1


Output

51
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll power(ll x, ll n){
    if(n == 0) return 1LL;
    ll res = power(x * x % MOD, n/2);
    if(n % 2 == 1) res = res * x % MOD;
    return res;
}
ll bitcnt[1LL<<22] = {};
ll number[1LL<<22] = {};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll a[100010];
    rep(i,0,N) cin >> a[i];
    ll ans = 0;
    vector<ll> uq;
    rep(i,0,N) uq.push_back(a[i]);
    sort(uq.begin(), uq.end());
    uq.erase(unique(uq.begin(), uq.end()), uq.end());
    rep(i,0,N) number[a[i]]++;

    for(auto &e: uq){
        for(int bit = e; ; bit = (bit-1) & e) {
            bitcnt[bit] += number[e];
            if (!bit) break;
        }   
    }

    // rep(i,0,N){
    //     for(int bit = a[i]; ; bit = (bit-1) & a[i]) {
    //         bitcnt[bit]++;
    //         if (!bit) break;
    //     }
    // }
    // ll num[22] = {};
    // rep(p,0,22){
    //     rep(i,0,N){
    //         if((a[i]>>p)&1) num[p]++;
    //     }
    // }

    rep(bit,1,(1LL<<21)){
        ll cnt = __builtin_popcount(bit);
        ll nn = bitcnt[bit];
        ll val = (power(2, nn) - 1 + MOD) % MOD;
        if(cnt % 2 == 1){
            ans += val;
        }else{
            ans -= val;
        }
        ans %= MOD;

    }
    ans = (power(2,N) - 1 - ans + MOD*2) % MOD;
    print(ans);

}
