#include using namespace std; constexpr int mod = 998244353; int dp[200001][2]; long long modpow(long long a,long long b) { long long ans = 1; while(b) { if(b & 1) { (ans *= a) %= mod; } (a *= a) %= mod; b /= 2; } return ans; } int main() { int N; cin >> N; dp[0][0] = 1; int cnt = 0; for(int i = 0; i < N; i++) { int B; cin >> B; if(N%2 == 1) { if(i == 0 || i+1 == N) { for(int j = 0; j < 2; j++) { if(B == 0 || B == -1) { dp[i+1][j] += dp[i][j]; dp[i+1][j] %= mod; } if(B == 1 || B == -1) { dp[i+1][j^1] += dp[i][j]; dp[i+1][j^1] %= mod; } } } else { if(B == -1) { cnt++; } for(int j = 0; j < 2; j++) { dp[i+1][j] = dp[i][j]; } } } if(N%2 == 0) { if(i <= N/4*2 || i+N/4*2 >= N) { for(int j = 0; j < 2; j++) { if(B == 0 || B == -1) { dp[i+1][j] += dp[i][j]; dp[i+1][j] %= mod; } if(B == 1 || B == -1) { dp[i+1][j^1] += dp[i][j]; dp[i+1][j^1] %= mod; } } } else { if(B == -1) { cnt++; } for(int j = 0; j < 2; j++) { dp[i+1][j] = dp[i][j]; } } } } cout << modpow(2,cnt)*dp[N][1]%mod << endl; }