#include #include using namespace std; using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; using mint = modint998244353; const int mod = 998244353; //const int INF = 1e9; //const long long LINF = 1e18; //const bool debug = false; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n-1); i >= 0; --i) #define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define endl "\n" #define P pair template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } mint dp[200005][2]; struct Lucas { public: //pは素数 Lucas(int p) :mod(p) { Init(); } private: //下準備 void Init() { CreateFact(); CreateComb(); } //comb計算 void CreateComb() { comb.resize(mod); rep(i, mod) { comb[i].resize(mod); rep(j, mod) { if (i < j) { comb[i][j] = 0; continue; } comb[i][j] = (((fact[i] * ifact[j]) % mod) * ifact[i - j]) % mod; } } } //階乗計算 void CreateFact() { fact.resize(mod); ifact.reserve(mod); fact[0] = 1; rep2(i, 1, mod) fact[i] = (fact[i - 1] * i) % mod; ifact[mod - 1] = inv(fact[mod - 1]); rrep2(i, 1, mod)ifact[i - 1] = (ifact[i] * i) % mod; } //逆元計算(x^(y - 2)) long long inv(long long x) { int y = mod - 2; long long tmp = x; long long ret = 1; while (y > 0) { if (1 == y % 2) { ret *= tmp; ret %= mod; } y /= 2; tmp *= tmp; tmp %= mod; } return ret; } public: //c(i,j)の計算 int c(long long i, long long j) { if (i < j) return 0; long long ret = 1; while (i > 0) { int x = i % mod; int y = j % mod; ret *= comb[x][y]; ret %= mod; i /= mod; j /= mod; } return ret; } //階乗デバッグ void debug() { rep(i, mod) cout << fact[i] << " "; cout << endl; rep(i, mod) cout << ifact[i] << " "; cout << endl; } //combデバッグ void debug2() { rep(i, mod) { rep(j, mod) cout << comb[i][j] << " "; cout << endl; } } //パスカルの三角形デバッグ void debug3() { rep(i, 10) { rep(j, i + 1) cout << c(i, j) << " "; cout << endl; } } private: long long mod; vector> comb; vectorfact; vectorifact; }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); Lucas ls(2); int n; cin >> n; vectora(n); rep(i, n)cin >> a[i]; dp[0][0] = 1; rep(i, n) { if (-1 != a[i]) { int x = ls.c(n - 1, i); rep(j, 2) { int nj = (j + x * a[i]) % 2; dp[i + 1][nj] += dp[i][j]; } } else { int x = ls.c(n - 1, i); rep(j, 2)rep(k, 2) { int nj = (j + x * k) % 2; dp[i + 1][nj] += dp[i][j]; } } } cout << dp[n][1].val() << endl; return 0; }