I=input L=I() L=1<<30 B=[[0,1]] for a in list(map(int,I().split()))+[0]: s,c,C=0,L,[] for b in B:s,c,C=(s+b[1])%998244353,a|b[0],C+[[],[[c,s]]][c>a|b[0]] B=C+[[c,s],[a,[0,s][c>a]]] print(B[-1][1])