#include #include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000001 int main(){ int N; cin>>N; vector b(N); rep(i,N)cin>>b[i]; vector dp(2,0); dp[0] = 1; rep(i,N){ vector ndp(2,0); rep(j,2){ if(b[i]!=-1&&j!=b[i])continue; rep(k,2){ if(((N-1)|(i))==(N-1)){ ndp[k^j] += dp[k]; } else{ ndp[k] += dp[k]; } } } swap(dp,ndp); } cout<