#include #include "testlib.h" using namespace std; #define MOD 998244353 int main() { registerValidation(); long long N = inf.readLong(2LL, 200000LL, "N"); inf.readEoln(); vector A(N); for (int i = 0; i < N; i++) { if (i != 0) inf.readSpace(); A[i] = inf.readLong(1LL, 1000000000LL, "A"); } inf.readEoln(); inf.readEof(); long long ans = 1; for (int i = 0; i < N - 1; i++) { ans = ans * min(A[i], A[i - 1]) % MOD; } cout << ans << endl; }