#include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; using ull = unsigned long long; using Graph = vector>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define NP next_permutation const int INF32 = 2e9; const ll INF64 = 2e18; const ll mod = 998244353; // const ll mod = 1e9 + 7; template bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;} template bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;} void cincout() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); } int main() { cincout(); int N; cin >> N; vector c(N); for (int i = 0; i < N; i++) cin >> c[i]; if (N == 1) { cout << 1 << endl; return 0; } using mint = modint998244353; mint ans = 1; if (c[0] < 0 && 0 < c[N - 1]) { int id = lower_bound(all(c), 0) - c.begin(); if (c[id] == 0) { ans *= 2 * 3 * mint(2).pow(max(0, N - 3)); } else ans *= 2 * mint(2).pow(max(N - 2, 0)); } else { if (c[0] == 0 || c[N - 1] == 0) ans *= 2 * mint(2).pow(max(N - 1, 0)); else ans *= 2 * mint(2).pow(N - 2); } cout << ans.val() << endl; }