#include #include #include #include #include using mint = atcoder::modint998244353; constexpr int L = 30; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; std::cin >> n; std::vector a(n); for (auto &&e : a) std::cin >> e; std::vector ppos; std::vector pd { 1 }; for (int i = 0; i < n; ++i) { std::vector pos { i }; int orv = a[i]; for (auto it = ppos.rbegin(); it != ppos.rend(); ++it) { const int p = *it, norv = orv | a[p]; if (norv != orv) { pos.push_back(p); orv = norv; } } std::reverse(pos.begin(), pos.end()); const int siz = pos.size(); std::vector dp(siz + 1); for (int k = 0, j = 0; k < siz; ++k) { while (j < int(ppos.size()) and ppos[j] <= pos[k]) ++j; dp[k + 1] = dp[k] + pd[j]; } pd.swap(dp); ppos.swap(pos); } std::cout << pd.back().val() << std::endl; return 0; }