def greedy(A): while len(A)>1: B=[] for i in range(len(A)-1): B.append(A[i]^A[i+1]) A=B return A[0] def nCr_mod2(n,r): while (n>0) or (r>0): if n&1==0 and r&1==1: return 0 n>>=1; r>>=1 return 1 def inner(A,B): X=0 for a,b in zip(A,B): X+=a*b return X #================================================== from itertools import product N=int(input()) B=list(map(int,input().split())) F=[nCr_mod2(N-1,r) for r in range(N)] Mod=998244353 DP=[1,0] for i,b in enumerate(B): if b==-1: E=DP.copy() if F[i]==0: DP[0]=2*DP[0]%Mod DP[1]=2*DP[1]%Mod else: DP[0]=DP[1]=(DP[0]+DP[1])%Mod print(DP[1])