#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::array last; last.fill(-1); std::vector ppos; std::vector pd { 1 }; for (int i = 0; i < n; ++i) { std::vector pos; for (int j = 0; j < L; ++j) { if ((a[i] >> j) & 1) { last[j] = i; } else if (last[j] >= 0) { pos.push_back(last[j]); } } std::sort(pos.begin(), pos.end()); pos.erase(std::unique(pos.begin(), pos.end()), pos.end()); pos.push_back(i); 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; }