#include #include #include #include #include using namespace std; template class modint { int val = 0; constexpr static int normalize(long long x) { if (0 <= x and x < mod) return static_cast(x); else { x %= mod; return static_cast(x >= 0 ? x : x + mod); } } public: static const int modulus = mod; modint() {} constexpr modint(long long n) : val(normalize(n)) {} constexpr int value() const { return val; } constexpr modint operator-() const { return modint(mod - val); } constexpr modint inverse() const { long long x = mod, y = val, p = 1, q = 0, r = 0, s = 1; while (y != 0) { long long u = x / y; long long x0 = y; y = x - y * u; x = x0; long long r0 = p - r * u, s0 = q - s * u; p = r; r = r0; q = s; s = s0; } return modint(q); } constexpr const modint pow(long long e) const { if (e < 0) return pow(-e).inverse(); long long ans = 1, p = val; while (e > 0) { if (e % 2 != 0) ans = (ans * p) % mod; p = (p * p) % mod; e >>= 1; } return modint(ans); } constexpr modint &operator+=(const modint r) { val += r.value(); if (val >= mod) val -= mod; return *this; } constexpr modint &operator-=(const modint r) { val -= r.value(); if (val < 0) val += mod; return *this; } constexpr modint &operator*=(const modint r) { val = (long long)val * r.value() % mod; return *this; } constexpr modint &operator/=(const modint r) { if (r.value() == 2) { val = (val % 2 ? val + mod : val) / 2; } else { val = (long long)val * r.inverse().value() % mod; } return *this; } friend constexpr modint operator+(const modint l, const modint r) { const int newval = l.value() + r.value(); return newval >= mod ? newval - mod : newval; } friend constexpr modint operator-(const modint l, const modint r) { return l + (- r); } friend constexpr modint operator*(const modint l, const modint r) { return (long long)l.value() * r.value(); } friend constexpr modint operator/(const modint l, const modint r) { return l * r.inverse(); } friend constexpr bool operator==(const modint l, const modint r) { return l.value() == r.value(); } friend constexpr bool operator!=(const modint l, const modint r) { return l.value() != r.value(); } }; constexpr int M = 998244353; using mint = modint; int main() { int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) cin >> a[i]; map v, p; p[a[0]] = 1; for (int i = 1; i < n; ++i) { v.clear(); mint total = 0; for (const auto [k, x] : p) total += x; mint sub = 0; v[a[i]] = total; for (const auto [k, x] : p) { if (v.find(a[i] | k) == v.end()) v[a[i] | k] += total - sub; sub += x; } v.swap(p); } mint ans = 0; for (auto [k, x] : p) ans += x; cout << ans.value() << endl; }