#include "atcoder/all" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const long long int INF = numeric_limits::max() / 4; const int inf = numeric_limits::max() / 4; const long long int MOD1000000007 = 1000000007; const long long int MOD998244353 = 998244353; const double MATH_PI = 3.1415926535897932; template inline void chmin(T1 &a, const T2 &b) { if (a > b) a = b; } template inline void chmax(T1 &a, const T2 &b) { if (a < b) a = b; } #define lint long long int #define ALL(a) a.begin(),a.end() #define RALL(a) a.rbegin(),a.rend() #define rep(i, n) for(int i=0;i<(int)(n);i++) #define VI vector #define VLL vector #define VC vector #define VB vector #define PI pair #define PLL pair #define VPI vector> #define VPLL vector> #define VVI vector> #define VVPI vecor>> #define VVPILL vector>> #define SUM(v) accumulate(ALL(v), 0LL) #define MIN(v) *min_element(ALL(v)) #define MAX(v) *max_element(ALL(v)) using mint = atcoder::modint998244353; int main() { int n; cin >> n; vector a(n); lint cnt = 0; rep (i, n) { cin >> a[i]; cnt += a[i] == -1; } int f = a.front(); int b = a.back(); if (f == 1 and b == 1) { cout << 0 << endl; return 0; } if (f == 0 and b == 0) { cout << 0 << endl; return 0; } if (f == -1 or b == -1) { cnt--; } cout << mint(2).pow(cnt).val() << endl; return 0; }