#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 1000000000 mint ans = 0; void go(vector a){ int now = 1; rep(i,a.size()-1){ now *= a[i]; if(now==-2){ ans += mint(2).pow(i+1).inv(); } } } void Go(vector a){ map mp; mp[1] = mint(2).inv(); int t = 1; rep(i,a.size()){ for(auto &x:mp){ x.second /= 2; } t *= a[i]; if(mp.count(-2/t))ans += mp[-2/t]; mp[t] += mint(2).inv(); } } int main(){ int N; cin>>N; vector a(N); rep(i,N){ cin>>a[i]; } go(a); reverse(a.begin(),a.end()); go(a); int t = 1; rep(i,N){ t *= a[i]; } if(t==-2){ ans += mint(2).pow(N-1).inv(); } if(N>=3){ a.erase(a.begin()); a.pop_back(); rep(i,a.size()){ if(a[i]==0)continue; vector T; while(i!=a.size()&&a[i]!=0){ T.push_back(a[i]); i++; } if(T.size()>0){ Go(T); } } } cout<