#include <cstring>
#include <iostream>

using namespace std;

typedef long long ll;

const int MOD = 998244353;
const int SZ = 1 << 18;
ll andtree[2 * SZ];
void andupd(int idx, ll val) {
  idx += SZ;
  andtree[idx] = val;
  while(idx > 1) {
    idx /= 2;
    andtree[idx] = andtree[2*idx] & andtree[2*idx+1];
  }
}
ll andqry(int lhs, int rhs) {
  ll ret = (1LL << 60) - 1;
  lhs += SZ;
  rhs += SZ;
  while(lhs <= rhs && ret) {
    if(lhs%2) ret &= andtree[lhs++];
    if(rhs%2==0) ret &= andtree[rhs--];
    lhs /= 2;
    rhs /= 2;
  }
  return ret;
}
ll sumtree[2 * SZ];
void sumupd(int idx, ll val) {
  idx += SZ;
  sumtree[idx] = val;
  while(idx > 1) {
    idx /= 2;
    sumtree[idx] = sumtree[2*idx] + sumtree[2*idx+1];
    sumtree[idx] %= MOD;
  }
}
ll sumqry(int lhs, int rhs) {
  ll ret = 0;
  lhs += SZ;
  rhs += SZ;
  while(lhs <= rhs) {
    if(lhs%2) ret += sumtree[lhs++];
    if(rhs%2==0) ret += sumtree[rhs--];
    lhs /= 2;
    rhs /= 2;
  }
  return ret;
}
ll l[200005];
int n;
int main() {
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> l[i];
    andupd(i, l[i]);
  }
  ll ret = 0;
  while(n && l[0] > 0) {
    {
      ll tot = l[0];
      for(int i = 1; i < n; i++) tot &= l[i];
      if(tot) {
        ll cand = 1;
        for(int i = 0; i < n; i++) {
          cand *= 2;
          cand %= MOD;
        }
        cand -= n;
        cand += MOD;
        ret += cand;
        ret %= MOD;
        break;
      }
    }
    memset(sumtree, 0, sizeof(sumtree));
    sumupd(0, 1);
    int olhs = 0;
    for(int i = 0; i < n; i++) {
      int lhs = olhs;
      int rhs = i;
      while(lhs < rhs) {
        int mid = (lhs+rhs)/2;
        if(andqry(mid, i)) rhs = mid;
        else lhs = mid+1;
      }
      sumupd(i+1, sumqry(lhs, i));
      olhs = lhs;
    }
    ll orig = l[0];
    ret += sumqry(n, n);
    ret %= MOD;
    while(n > 1) {
      l[0] &= l[--n];
      if(l[0] != orig) break;
      ret += sumqry(n, n);
      ret %= MOD;
    }
    andupd(0, l[0]);
  }
  cout << ret << "\n";
}