const MOD: usize = 998244353; fn is_odd(n: usize, k: usize) -> bool { (n & k) == k } 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![0usize; n+1]; let mut total = 1usize; for i in 0..n { let odd = is_odd(n-1, i); if b[i] == -1 { if odd { dp[i+1] = total; } else { dp[i+1] = 2*dp[i] % MOD; } total *= 2; total %= MOD; } else if b[i] == 1 && odd { dp[i+1] = MOD + total - dp[i]; dp[i+1] %= MOD; } else { dp[i+1] = dp[i]; } } println!("{}", dp[n]); }