#include using namespace std; using ll = long long; ll const m = 998244353; int main () { int N; cin >> N; ll pre; cin >> pre; ll ans = 1; for (int i = 1; i < N; i ++) { ll a; cin >> a; ans *= min(a, pre); ans %= m; pre = a; } cout << ans << endl; }