#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 100000000000000000 int main(){ int N; cin>>N; vector a(N); rep(i,N){ cin>>a[i]; } map dp; dp[1] = 1; mint ans = 0; rep(i,N){ map ndp; for(auto x:dp){ int t = x.first * a[i]; if(t<=-3||t>=3)t = 3; ndp[t] += x.second; } if(i!=0)ndp[a[i]] += mint(2).pow(i-1); ans += ndp[-2] * mint(2).pow(max(0,(N-2)-i)); swap(dp,ndp); //cout<