#include #define fi first #define se second #define pb push_back #define sz(a) (int)a.size() #define all(a) a.begin(),a.end() #define rep(i,n) for(int i=0;i=0;i--) #define vec(...) vector<__VA_ARGS__> #define _3pPbCt8 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0) using namespace std; typedef long long ll; typedef long double ld; using pii=pair; using vi=vector; //snuke's modular int template struct modularint{ ll x; modularint(ll x=0):x(x%mod){} modularint& operator+=(const modularint a){ if ((x += a.x) >= mod) x -= mod; return *this; } modularint& operator-=(const modularint a){ if ((x += mod-a.x) >= mod) x -= mod; return *this; } modularint& operator*=(const modularint a){ (x *= a.x) %= mod; return *this; } modularint operator+(const modularint a)const{ modularint res(*this); return res+=a; } modularint operator-(const modularint a)const{ modularint res(*this); return res-=a; } modularint operator*(const modularint a)const{ modularint res(*this); return res*=a; } modularint pow(ll n)const{ modularint res=1,x(*this); while(n){ if(n&1)res*=x; x*=x; n>>=1; } return res; } modularint inv()const{ return pow(mod-2); } }; using mint=modularint<998244353>; //https://cp-algorithms.com/combinatorics/binomial-coefficients.html //https://en.wikipedia.org/wiki/Lucas's_theorem ll cenk(ll x,ll y) { if(x==y or x==0) return 1; if(x>y) return 0; return cenk(x-1,y)+cenk(x-1,y-1); } ll cnk(ll k , ll n){ if(k>n) return 0; ll c=1; while(n>0) { c *= cenk(k%2,n%2); c%=2; n/=2; k/=2; } return c; } int main(){ _3pPbCt8; // prefact(); int n; cin>>n; vi a(n); rep(i,n){ cin>>a[i]; } vec(vec(mint)) dp(n+1,vec(mint)(2,0)); dp[0][0]=1; rep(i,n){ rep(x,2){ if(a[i]!=-1) x=a[i]; int e=x*cnk(i,n-1)%2; e%=2; rep(ox,2){ dp[i+1][(e+ox)%2]+=dp[i][ox]; } if(a[i]!=-1) break; } } cout<