def combmod2(n, r): return (n & r) != r def solve(n, a): dp = [[0] * 2 for _ in range(n + 1)] dp[0][0] = 1 mod = 998244353 for i in range(n): if a[i] != -1: if combmod2(n - 1, i): dp[i + 1][1] = dp[i][1] dp[i + 1][0] = dp[i][0] else: dp[i + 1][1] += dp[i][(1 + a[i]) % 2] dp[i + 1][a[i]] += dp[i][a[i] % 2] else: if combmod2(n - 1, i): 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()) a = list(map(int,input().split())) print(solve(n, a))