#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define pb emplace_back
#define fi first
#define se second
#define mkp make_pair
const ll mod = 998244353;
inline ll read() { ll x; scanf("%lld",&x); return x; }
inline ll lg2(ll x){ return 63^__builtin_clzll(x); }
inline ll qpow(ll a,ll b){
ll ans=1, base=a;
while(b){
if(b&1) ans=ans*base%mod;
base=base*base%mod; b>>=1;
}
return ans;
}
void init(){ }
const ll B = 40;
ll n,a[200005],w[B+5],fa[B+5],pt[B+5],cnt,ind[B+5],vis[B+5];
vector<ll>E[B+5];
ll find(ll x){ if(x!=fa[x]) fa[x]=find(fa[x]); return fa[x]; }
struct Graph{
ll N, d[B+5], p, q;
ll d1[B+5], d2[B+5], d3[B+5];
inline void addedge(ll x,ll y){
d[x] |= (1<<y);
}
ll g[1<<20];
ll solve(){
ll p = N/2, q = N-p;
for(ll i=0;i<p;i++){
d1[i] = (d[i] & ((1ll<<p)-1));
d3[i] = (d[i] >> p);
}
for(ll i=0;i<q;i++){
d2[i] = (d[p+i] >> p);
}
for(ll i=0;i<(1<<q);i++){
g[i]=1;
for(ll j=0;j<q;j++){
if(((i>>j)&1) && ((i&d2[j])!=d2[j])){
g[i]=0;
break;
}
}
}
for(ll i=0;i<q;i++){
for(ll j=(1<<q)-1;j>=0;j--){
if((j>>i)&1)
g[j^(1<<i)] += g[j];
}
}
ll ans = 0;
for(ll i=0;i<(1<<p);i++){
ll flg=1, nd=0;
for(ll j=0;j<p;j++){
if(((i>>j)&1)){
nd |= d3[j];
if((i&d1[j])!=d1[j]){
flg=0; break;
}
}
}
if(flg){
ans += g[nd];
}
}
return ans;
}
}G;
void procedure(){
n=read(), chk=(1ll<<B)-1;
for(ll i=0;i<B;i++) w[i]=(1ll<<B)-1, fa[i]=i;
for(ll i=1;i<=n;i++){
a[i]=read(); chk&=a[i];
for(ll j=0;j<B;j++){
if((a[i]>>j)&1) vis[j]=1, w[j]&=a[i];
}
}
for(ll i=0;i<B;i++){
if(!vis[i]) continue;
}
for(ll i=0;i<B;i++){
if(!vis[i]) continue;
for(ll j=i+1;j<B;j++){
if(!vis[j]) continue;
if(((w[i]>>j)&1) && ((w[j]>>i)&1)){
fa[find(i)] = find(j);
}
}
}
unordered_set<ll>S;
for(ll i=0;i<B;i++){
if(!vis[i]) continue;
S.insert(find(i));
for(ll j=0;j<B;j++){
if(i==j || !vis[j]) continue;
if((w[i]>>j)&1){
if(find(i) == find(j)) continue;
E[find(i)].pb(find(j));
ind[find(j)]++;
}
}
}
queue<ll>q;
for(auto x: S) if(!ind[x]) q.push(x);
while(!q.empty()){
ll x=q.front(); q.pop(); pt[x] = (cnt++);
for(auto y: E[x]){
ind[y]--;
if(!ind[y]) q.push(y);
}
}
G.N = cnt;
for(ll i=0;i<B;i++){
if(!vis[i]) continue;
for(auto j: E[i]){
G.addedge(pt[i], pt[j]);
}
}
printf("%lld\n", G.solve() - (!!chk));
}
int main(){
#ifdef LOCAL
assert(freopen("input.txt","r",stdin));
assert(freopen("output.txt","w",stdout));
#endif
ll T=1; init();
// T=read();
while(T--) procedure();
return 0;
}