#include #include using namespace std; typedef long long ll; const int MOD = 998244353; const int D = 18; const int SZ = 1 << D; ll andst[200005][D]; int sump[200005]; ll l[200005]; int n; int main() { cin >> n; for(int i = 0; i < n; i++) { cin >> l[i]; andst[i][0] = l[i]; } { for(int d = 1; d < D; d++) { for(int i = 0; i < n; i++) { andst[i][d] = andst[i][d-1]; if(i + (1 << (d - 1)) < n) { andst[i][d] &= andst[i + (1 << (d - 1))][d-1]; } else { andst[i][d] = 0; } } } } int ret = 0; while(n && l[0] > 0) { { ll tot = l[0]; for(int i = 1; i < n; i++) tot &= l[i]; if(tot) { ll cand = 1; for(int i = 0; i < n; i++) { cand *= 2; cand %= MOD; } cand -= n; cand += MOD; ret += cand; ret %= MOD; break; } } sump[1] = 1; for(int i = 0; i < n; i++) { int lhs = i; ll currv = l[i]; for(int d = D-1; d >= 0; d--) { if(lhs-(1<= 0 && (currv & (andst[lhs - (1<= MOD) sump[i+2] -= MOD; } ll orig = l[0]; ret += sump[n+1] - sump[n]; if(ret < 0) ret += MOD; if(ret >= MOD) ret -= MOD; while(n > 1) { l[0] &= l[--n]; if(l[0] != orig) break; ret += sump[n+1] - sump[n]; if(ret < 0) ret += MOD; if(ret >= MOD) ret -= MOD; } andst[0][0] = l[0]; for(int d = 1; d < D; d++) { andst[0][d] = andst[0][d-1]; if((1 << (d-1)) < n) { andst[0][d] &= andst[1 << (d-1)][d-1]; } else { andst[0][d] = 0; } } } cout << ret << "\n"; }