def comb(n, r, mod): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod mod = 10**9+7 #出力の制限 N = 10**4 g1 = [1, 1] # 元テーブル g2 = [1, 1] #逆元テーブル inverse = [0, 1] #逆元テーブル計算用テーブル for i in range( 2, N + 1 ): g1.append( ( g1[-1] * i ) % mod ) inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod ) g2.append( (g2[-1] * inverse[-1]) % mod ) def solve(n, b): dp = [[0] * 2 for _ in range(n + 1)] dp[0][0] = 1 mod = 998244353 for i in range(n): if b[i] != -1: if comb(n - 1, i, 2): dp[i + 1][1] = dp[i][1] dp[i + 1][0] = dp[i][0] else: dp[i + 1][1] += dp[i][(1 + b[i]) % 2] dp[i + 1][0] += dp[i][b[i] % 2] else: if comb(n - 1, i, 2): dp[i + 1][1] += 2 * dp[i][1] dp[i + 1][0] += 2 * dp[i][0] else: dp[i + 1][1] += dp[i][0] + dp[i][1] dp[i + 1][0] += dp[i][0] + dp[i][1] dp[i + 1][1] %= mod dp[i + 1][0] %= mod return dp[n][1] n = int(input()) b = list(map(int,input().split())) print(solve(n, b))