/* -*- coding: utf-8 -*- * * 2275.cc: No.2275 →↑↓ - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 200000; const int MOD = 998244353; /* typedef */ typedef long long ll; /* global variables */ int as[MAX_N]; /* subroutines */ /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", as + i); int p = 1; for (int i = 0; i + 1 < n; i++) p = (ll)p * min(as[i], as[i + 1]) % MOD; printf("%d\n", p); return 0; }