import sys input = sys.stdin.readline N = int(input()) a = list(map(int, input().split())) mod = 998244353 class Factorial: def __init__(self, n, mod): self.mod = mod self.f = [1] for i in range(1, n + 1): self.f.append(self.f[-1] * i % mod) self.i = [pow(self.f[-1], mod - 2, mod)] for i in range(1, n + 1)[: : -1]: self.i.append(self.i[-1] * i % mod) self.i.reverse() def factorial(self, i): return self.f[i] def ifactorial(self, i): return self.i[i] def combi(self, n, k): return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod def permi(self, n, k): return self.f[n] * self.i[n - k] % self.mod f = Factorial(N, 2) def lucas(n, k): res = 1 while n and k: res &= f.combi(n % 2, k % 2) n >>= 1 k >>= 1 return res dp = [0] * 2 dp[0] = 1 for i in range(N): if a[i] == 1: c = lucas(N - 1, i) if c: dp[0], dp[1] = dp[1], dp[0] if a[i] == -1: c = lucas(N - 1, i) if c: dp[0], dp[1] = dp[0] * 2 % mod, dp[1] * 2 % mod else: dp[0], dp[1] = (dp[0] + dp[1]) % mod, (dp[0] + dp[1]) % mod print(dp[-1])