#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5, M = (1 << 20), B = 40;
int n, m;
ll a[N], f[M], d[B], h[B], ans;
bool ok[B], g[B][B];
vector <int> ch, tp;
int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int k = 0; k < B; k++)
{
ll val = (1ll << 40) - 1; int cnt = 0;
for (int i = 1; i <= n; i++)
if (a[i] & (1 << k))
val &= a[i], cnt++;
if (cnt && cnt < n)
{
ok[k] = 1;
for (int j = 0; j < 40; j++)
if (val & (1 << j)) g[k][j] = 1;
}
}
for (int k = 0; k < B; k++)
{
if (!ok[k]) continue;
bool fl = 1;
for (int j : ch)
if (g[k][j] && g[j][k])
fl = 0;
if (fl) ch.push_back(k);
}
m = ch.size();
for (int i : ch) for (int j : ch) if (g[i][j] && i != j) d[j]++;
for (int i : ch) if (!d[i]) tp.push_back(i);
for (int i = 0; i < m; i++) for (int j : ch)
if (g[tp[i]][j] && tp[i] != j) if (!--d[j]) tp.push_back(j);
assert(t.size() == m);
for (int k = 0; k < m; k++) for (int j = 0; j < m; j++)
if (g[tp[k]][tp[j]]) h[k] |= (1ll << j);
int L = (m >> 1), R = m - L;
for (int S = 0; S < (1 << R); S++)
{
ll val = 0;
for (int j = 0; j < R; j++) if (S & (1 << j))
val |= h[L+j] >> L;
if (val == S) f[S]++;
}
for (int S = 1; S < (1 << R); S <<= 1)
for (int _S = 0; _S < (1 << R); _S += (S << 1))
for (int T = 0; T < S; T++)
f[_S+T] += f[S+_S+T];
for (int S = 0; S < (1 << L); S++)
{
ll val = 0;
for (int j = 0; j < L; j++) if (S & (1 << j))
val |= h[j];
if (S == (val & (1 << L) - 1)) ans += f[val>>L];
}
cout << ans << "\n";
return 0;
}