#include <iostream> #include <vector> using namespace std; using ll = long long; const ll mod = 998244353; int main() { int N; cin >> N; vector<int> c(N); for (ll i = 0; i < N; i++) { cin >> c[i]; } bool exist_0 = false; for (int i = 0; i < N; i++) { if (c[i] == 0) { exist_0 = true; } } ll ans = 1; if (exist_0 && c[N - 1] > 0 && c[0] < 0) { ans = (ans * 3LL) % mod; for (int i = 0; i < N - 2; i++) { ans = (ans * 2LL) % mod; } } else { for (int i = 0; i < N - 1; i++) { ans = (ans * 2LL) % mod; } } cout << ans << endl; }