#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))

const int INF = (int)1E9;
#define MAXN 200005
const int mod = 998244353;
int n;
ll a[MAXN], rAnd[MAXN];
int nzLeft[MAXN], s[MAXN];
void add(int k, int v){
	k++;
	for(;k<MAXN;k+=-k&k) s[k] = (s[k] + v) % mod;
}
int get(int k){
	if (k < 0) return 0;
	k++;
	int ans = 0;
	for(;k;k-=-k&k) ans = (ans + s[k]) % mod;
	return ans;
}
int solve(ll leftAnd) {
  FILL(s, 0);
  int sol = 0;
  ll leftRoll = -1;
  int iEnd = leftAnd == 0 ? n : n - 1;
  int lastPre = 0;
  REP(i,0,iEnd) {
    leftRoll &= a[i];
    int pre = get(n - 1 - max(0, nzLeft[i] - 1));
    if (leftAnd > 0 && (rAnd[i + 1] & leftAnd) > 0) sol = (sol + pre) % mod;
    if ((leftAnd > 0 && leftRoll == leftAnd) || (leftAnd == 0 && leftRoll > 0)) pre = (pre + 1) % mod;
    add(n - 1 - i, pre);
    lastPre = pre;
  }
  if (leftAnd == 0) return lastPre;
  return sol;
}
int main() {
  cin >> n;
  set<ll> leftAnd;
  ll la = -1;
  VI lastZero(60, -1);
  REP(i,0,n) {
    cin >> a[i];
    la &= a[i];
    leftAnd.insert(la);
    nzLeft[i] = i;
    REP(b,0,60) {
      if ((a[i] & (1LL << b)) == 0) lastZero[b] = i;
      nzLeft[i] = min(nzLeft[i], lastZero[b] + 1);
    }
  }
  leftAnd.insert(0);
  rAnd[n] = -1;
  for (int i = n - 1; i >= 0; i--) rAnd[i] = a[i] & rAnd[i + 1];
  int ans = 0;
  for (auto &v: leftAnd)
    ans = (ans + solve(v)) % mod;
  cout << ans << endl;
  return 0;
}
