#include using namespace std; const int M = 998244353; int main() { cin.tie(0); ios::sync_with_stdio(0); int n; cin >> n; vector a(n); vector pw(n + 1); pw[0] = 1; int inv = (M + 1) / 2; for (int i = 0; i < n; ++i) { cin >> a[i]; pw[i + 1] = pw[i] * inv % M; } long long ans = 0; for (int i = 0; i < n; ++i) { int b = 1; for (int j = i; j < n; ++j) { b *= a[j]; if (b == -2) { int c = j - i + 2 - (i == 0) - (j == n - 1); ans = (ans + pw[c]) % M; } if (b == 0 || abs(b) > 2) break; } } cout << ans << '\n'; return 0; }