mod = 998244353 N = int(input()) A = list(map(int, input().split())) ans = 0 for i in range(1,N-1): if abs(A[i])==2: l_p = pow(2,i-1,mod) l_m = 0 cuml = 1 for j in range(i-1,0,-1): if abs(A[j])!=1: break cuml *= A[j] if cuml == 1: l_p += pow(2,j-1,mod) else: l_m += pow(2,j-1,mod) r_p = pow(2,N-2-i,mod) r_m = 0 cumr = 1 for j in range(i+1,N-1): if abs(A[j])!=1: break cumr *= A[j] if cumr == 1: r_p += pow(2,N-2-i,mod) else: r_m += pow(2,N-2-i,mod) if A[i]==2: ans += l_p * r_m + l_m * r_p else: ans += l_p * r_p + l_m * r_m ans %= mod cum = 1 for i in range(N): cum *= A[i] if cum == -2: if i2 or cum==0: break cum = 1 for i in range(N-1,0,-1): cum *= A[i] if cum == -2: ans += pow(2,i-1,mod) if abs(cum)>2 or cum==0: break ans %= mod ans *= pow(pow(2,N-1,mod),mod-2,mod) print(ans%mod)