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 { for j in 0..2 { if dp[i][j] == 0 { continue; } let odd = (n-1) & i == i; if b[i] == -1 { dp[i+1][j] += dp[i][j] + if !odd { dp[i][j] } else { 0 }; dp[i+1][j^1] += if odd { dp[i][j] } else { 0 }; dp[i+1][j] %= MOD; dp[i+1][j^1] %= MOD; } else { let val = if odd && b[i] == 1 { 1 } else { 0 }; dp[i+1][j^val] += dp[i][j]; dp[i+1][j^val] %= MOD; } } } println!("{}", dp[n][1]); }