#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include using namespace std; const int MOD = 998244353; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int N; cin >> N; vector A(N); for(int i = 0; i < N; i++){ cin >> A[i]; } vector dp(N); dp[0] = 1; long long all = 1; vector prev(30, -1); for(int i = 0; i < N; i++){ for(int j = 0; j < 30; j++){ if(A[i] >> j & 1){ prev[j] = i; } } auto idx = prev; sort(idx.begin(), idx.end()); idx.erase(unique(idx.begin(), idx.end()), idx.end()); long long rem = all; int r = i; for(int j = (int)idx.size() - 1; j >= 0; j--){ if(idx[j] != i && idx[j] != -1){ while(idx[j] < r){ rem -= dp[r--]; } rem = (rem % MOD + MOD) % MOD; dp[idx[j] + 1] = (rem + dp[idx[j] + 1]) % MOD; all = (all + rem) % MOD; } } } cout << all << endl; }