N = int(input()) B = list(map(int, input().split())) MOD = 998244353 def ord2(n): i = 0 while not n % 2: i += 1 n >>= 1 return i comb = [0]*N for i in range(1, N): comb[i] = comb[i-1]+ord2(N-i)-ord2(i) cta = 0 ctb = 0 v = 0 for i in range(N): if not comb[i]: if B[i] == -1: cta += 1 else: v ^= B[i] else: if B[i] == -1: ctb += 1 if v == cta == 0: print(0) else: print(pow(2, ctb+max(0, cta-1), MOD))