#include using namespace std; #ifdef _RUTHEN #include #else #define show(...) true #endif #define REP(i, n) for (int i = 0; i < (n); i++) template using V = vector; #include using mint = atcoder::modint998244353; int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector A(N); REP(i, N) cin >> A[i]; mint ans = 1; REP(i, N - 1) ans *= min(A[i], A[i + 1]); cout << ans.val() << '\n'; return 0; }