N = int(input()) A = list(map(int,input().split())) mod = 998244353 inv = pow(2,mod-2,mod) res = 0 for i in range(N): if abs(A[i])==2: base = pow(2,max(i-1,0),mod) left_pos = base left_nega = 0 prod = 1 if i!=1: base = (base * inv) % mod for j in range(1,i+1): if abs(A[i-j])==1: prod *= A[i-j] if prod>0: left_pos += base else: left_nega += base else: break if j!=i-1: base = (base * inv) % mod base = pow(2,max(0,N-i-2),mod) right_pos = base right_nega = 0 prod = 1 if i!=N-2: base = (base * inv) % mod for j in range(1,N-i): print(base) if abs(A[i+j])==1: prod *= A[i+j] if prod>0: right_pos += base else: right_nega += base else: break if j!=N-i-2: base = (base * inv) % mod if A[i]==2: res += left_pos * right_nega + left_nega * right_pos else: res += left_pos * right_pos + left_nega * right_nega res %= mod #print(left_pos,left_nega,right_pos,right_nega) #print(res) ans = res * pow(2,(N-1)*(mod-2),mod) print(ans%mod)