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] #================================================== N=int(input()) B=list(map(int,input().split())) Mod=998244353 Q=B[1:-1].count(-1); Q_exp=pow(2,Q,Mod) X=0 for a in [0,1]: for b in [0,1]: if B[0] in {-1,a} and B[-1] in {-1,b} and a!=b: X+=Q_exp print(X%Mod)