#include #include using namespace std; using mint = atcoder::modint998244353; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int n; cin >> n; vector b(n); for (int i = 0; i < n; i++) { cin >> b[i]; } vector cnt(n); for (int i = 1; i < n; i++) { int p = 2; while (p <= i) { cnt[i] += i / p; p *= 2; } } vector> dp(n + 1, vector(2, 0)); dp[0][0] = 1; for (int i = 0; i < n; i++) { if (cnt[n - 1] > cnt[i] + cnt[n - 1 - i]) { if (b[i] == -1) { dp[i + 1][0] = 2 * dp[i][0]; dp[i + 1][1] = 2 * dp[i][1]; } else { dp[i + 1][0] = dp[i][0]; dp[i + 1][1] = dp[i][1]; } } else { if (b[i] == -1) { dp[i + 1][0] = dp[i + 1][1] = dp[i][0] + dp[i][1]; } else if (b[i] == 0) { dp[i + 1][0] = dp[i][0]; dp[i + 1][1] = dp[i][1]; } else { dp[i + 1][0] = dp[i][1]; dp[i + 1][1] = dp[i][0]; } } } cout << dp[n][1].val() << endl; }