#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>; int main(){ _3pPbCt8; 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(ox,2){ int now; rep(x,2){ if(a[i]!=-1) x=a[i]; if(i==0 or i==n-1) now=x; else now=(((n-1)%2)*x)%2; dp[i+1][(ox+now)%2]+=dp[i][ox]; if(a[i]!=-1) break; } } } mint ans=dp[n][1]; cout<