const MOD: usize = 998244353; fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut b = String::new(); std::io::stdin().read_line(&mut b).ok(); let b: Vec = b.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let mut dp = vec![vec![0usize; 2]; n+1]; dp[0][0] = 1; for i in 0..n { let is_odd = (n-1) & i == i; let pat = if is_odd { 1 } else { 0 }; match b[i] { -1 => { dp[i+1][0] = (dp[i][0] + dp[i][0^pat]) % MOD; dp[i+1][1] = (dp[i][1] + dp[i][1^pat]) % MOD; }, 0 => { dp[i+1][0] = dp[i][0]; dp[i+1][1] = dp[i][1]; }, 1 => { dp[i+1][0] = dp[i][0^pat]; dp[i+1][1] = dp[i][1^pat]; }, _ => { unreachable!(); } } } println!("{}", dp[n][1]); }