from sys import stdin n, *b = map(int, stdin.read().split()) p = 998244353 def powmod(n,pow,mod): val = 1 while pow > 0: if pow & 1: val = (val * n) % mod pow = pow >> 1 n = (n * n) % mod return val numof2 = [0 for i in range(n+1)] val = 2 while val <= n: kari = val while kari <= n: numof2[kari] += 1 kari += val val = val * 2 kaijo = [0 for i in range(n+1)] for i in range(1,n+1): kaijo[i] = kaijo[i-1] + numof2[i] nowans = 0 oddnum = 0 evennum = 0 for i in range(n): kari = kaijo[n-1] - kaijo[i] - kaijo[n-1-i] if kari >= 1: if b[i] == -1: evennum += 1 else: if b[i] == -1: oddnum += 1 else: nowans = nowans ^ b[i] if oddnum == 0: if nowans == 0: print("{}".format(0)) else: ans = powmod(2,evennum,p) print("{}".format(ans)) else: ans = powmod(2,evennum+oddnum-1,p) print("{}".format(ans))