#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) { if (abs(a[i]) < 2) continue; vector c = { pw[min(i, 1)], 0 }; int s = 1; for (int j = i - 1; j >= 0; --j) { s *= a[j]; if (s == 1) { c[0] = (c[0] + pw[min(i, i - j + 1)]) % M; } else if (s == -1) { c[1] = (c[1] + pw[min(i, i - j + 1)]) % M; } else break; } int b = 1; for (int j = i; j < n; ++j) { b *= a[j]; if (b == -2) { ans = (ans + c[0] * pw[min(n - i - 1, j - i + 1)]) % M; } else if (b == 2) { ans = (ans + c[1] * pw[min(n - i - 1, j - i + 1)]) % M; } else break; } } cout << ans << '\n'; return 0; }