#include using namespace std; typedef long long ll; ll mod = 998244353,inv[200010],b[4] = {},ans1 = 0,ans2 = 0; int a[200010]; ll pw(ll a,ll x){ ll ret = 1; while(x){ if(x&1) (ret *= a) %= mod; (a *= a) %= mod; x /= 2; } return ret; } int main(){ int i,n; cin >> n; for(i=0;i> a[i]; if(n==1){ if(a[0]==-2) cout << 1 << endl; else cout << 0 << endl; return 0; } inv[0] = 1,inv[1] = (mod + 1)/2; for(i=2;i<=n;i++) inv[i] = inv[i - 1]*inv[1]%mod; ll c = a[0]; if(c==-2) (ans1 += inv[1]); for(i=1;i2 || c<-2) break; if(c==-2) (ans1 += inv[i + 1]) %= mod; } c = a[n - 1]; if(c==-2) (ans1 += inv[1]) %= mod; for(i=n - 2;i>=1;i--){ c *= a[i]; if(c>2 || c<-2) break; if(c==-2) (ans1 += inv[n - i]) %= mod; } c = 1; for(i=0;i2 || c<-2) break; } if(c==-2) (ans1 += inv[n - 1]) %= mod; //b[0]=-2,b[1]=-1,b[2]=1,b[3]=2 for(i=1;i=3) (ans2 *= inv[2]) %= mod; cout << (ans1 + ans2)%mod << endl; }