#include <algorithm>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

constexpr int MOD = 998244353;

int main() {
    int n;
    cin >> n;

    vector<int64_t> a(n);
    int64_t and_all = (1LL << 62) - 1;
    for (auto& x : a) {
        cin >> x;
        and_all &= x;
    }

    int ans = and_all > 0;
    while (!a.empty() && a[0] != 0) {
        vector<int> dp(a.size() + 1, 0);
        dp[a.size()] = 1;
        for (int i = static_cast<int>(a.size()) - 1; i > 0; --i) {
            int64_t val = a[i];
            for (int j = i; j < a.size(); ++j) {
                val &= a[j];
                if (val == 0) {
                    break;
                }

                dp[i] += dp[j + 1];
                if (dp[i] >= MOD)
                    dp[i] -= MOD;
            }
        }

        /*
        cerr << "Array is";
        for (auto x : a) {
            cerr << " " << x;
        }
        cerr << endl;

        cerr << "DP is";
        for (auto x : dp) {
            cerr << " " << x;
        }
        cerr << endl;
        */

        int64_t val = a[0];
        for (int r = 0; r + 1 < a.size(); ++r) {
            val &= a[r];
            if (val == 0) {
                break;
            }

            ans += dp[r + 1];
            if (ans >= MOD)
                ans -= MOD;
        }

        a[0] &= a.back();
        a.pop_back();
    }

    cout << ans << '\n';

    return 0;
}
