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 pattern = if (n-1)&i == i { 1 } else { 0 }; if b[i] == -1 { dp[i+1][0] = dp[i][0] + dp[i][pattern]; dp[i+1][1] = dp[i][1] + dp[i][1-pattern]; dp[i+1][0] %= MOD; dp[i+1][1] %= MOD; } else if b[i] == 0 { dp[i+1][0] = dp[i][0]; dp[i+1][1] = dp[i][1]; } else { dp[i+1][0] = dp[i][pattern]; dp[i+1][1] = dp[i][1-pattern]; } } println!("{}", dp[n][1]); }