import typing MOD = 998244353 #https://ikatakos.com/pot/programming_algorithm/data_structure/binary_indexed_tree class Bit: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] if s >= MOD: s -= MOD i -= i & -i return s def add(self, i, x): i += 1 while i <= self.size: self.tree[i] += x if self.tree[i] >= MOD: self.tree[i] -= MOD i += i & -i N = int(input()) A = list(map(int,input().split())) dp = Bit(N) dp.add(0, 1) prev = [-1] * 30 for i in range(N): for j in range(30): if (A[i] >> j) & 1: prev[j] = i idx = sorted(list(set(prev)), reverse=True) for j in idx: if j != i: dp.add(j + 1, dp.sum(j + 1)) print(dp.sum(N))