N = int(input()) B = list(map(int,input().split())) P = 998244353 power = [0] * N i = 2 while i < N: for j in range(1,(N-1)//i + 1): power[i*j] += 1 i *= 2 now = 0 count1 = 0 count2 = 0 S = 0 if B[0] == -1: count1 += 1 else: S += B[0] if B[N-1] == -1: count1 += 1 else: S += B[0] for i in range(1,N-1): now = now + power[N-i] - power[i] if now > 0: if B[i] == -1:count2 += 1 else: if B[i] == -1:count1 += 1 else:S += B[i] if count1 == 0 and S % 2 == 0: print(0) exit() if count1 == 0:u = count2 else:u = count1 + count2 -1 u = count1 + count2 - 1 t = 1 for _ in range(u): t *= 2 t %= P print(t)