import sys input=sys.stdin.readline MOD=998244353 def main(): N=int(input()) a=list(map(int,input().split())) pw2=[1]*(N+1) for i in range(N): pw2[i+1]=(pw2[i]*2)%MOD ans=0 for i in range(N): if abs(a[i])==2: prod=0 cl=[pw2[max(0,i-1)],0] for j in range(i-1,-1,-1): if abs(a[j])==1: if a[j]==-1: prod^=1 cl[prod]=(cl[prod]+pw2[max(0,j-1)])%MOD else: break prod=0 cr=[pw2[max(0,N-2-i)],0] for j in range(i+1,N): if abs(a[j])==1: if a[j]==-1: prod^=1 cr[prod]=(cr[prod]+pw2[max(0,N-2-j)])%MOD else: break if a[i]==2: ans=(ans+cl[0]*cr[1]+cl[1]*cr[0])%MOD else: ans=(ans+cl[0]*cr[0]+cl[1]*cr[1])%MOD ans*=pow(pow(2,N-1,MOD),MOD-2,MOD) ans%=MOD print(ans) if __name__=='__main__': main()