MOD = 998244353 n = int(input()) a = list(map(int, input().split())) dp = [[1, 0], [0, 0]] # [abs is 2][sig is neg] ans = 0 for z, x in enumerate(a): ndp = [[0, 0], [0, 0]] if x == 2: ndp[1][0] = dp[0][0] ndp[1][1] = dp[0][1] elif x == -2: ndp[1][0] = dp[0][1] ndp[1][1] = dp[0][0] elif x == 1: for i in range(2): for j in range(2): ndp[i][j] = dp[i][j] elif x == -1: for i in range(2): for j in range(2): ndp[i][j] = dp[i][1-j] ans = (ans + ndp[1][1] * pow(2, max(0, n - 2 - z), MOD)) % MOD ndp[0][0] += pow(2, z, MOD) ndp[0][0] %= MOD dp = ndp q = pow(2, n-1, MOD) print(ans * pow(q, MOD-2, MOD) % MOD)