#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) template using vi = vector; template using vii = vector>; template using viii = vector>; using P = pair; void chmin(ll & x, ll y) { x = min(x, y); } void chmax(ll& x, ll y) { x = max(x, y); } struct mint { const long long mod = 998244353; long long x; mint(long long x_ = 0) : x((x_% mod + mod) % mod) {} mint& operator+=(const mint& other) { x += other.x; if (x >= mod) x -= mod; return *this; } mint& operator-=(const mint& other) { x -= other.x; if (x < 0) x += mod; return *this; } mint& operator*=(const mint& other) { x *= other.x; x %= mod; return *this; } mint& operator+=(const long long n) { return *this += mint(n); } mint& operator-=(const long long n) { return *this -= mint(n); } mint& operator*=(const long long n) { return *this *= mint(n); } mint& operator=(const mint& other) { x = other.x; return *this; } mint& operator=(const long long n) { x = n % mod; return *this; } bool operator==(const mint& other) const { return x == other.x; } bool operator!=(const mint& other) const { return x != other.x; } mint operator-() const { mint res(mod - x); return res; } mint operator+(const mint& other) const { mint res(x); return res += other; } mint operator-(const mint& other) const { mint res(x); return res -= other; } mint operator*(const mint& other) const { mint res(x); return res *= other; } mint operator+(const long long n) const { mint res(x); mint other(n); return res += other; } mint operator-(const long long n) const { mint res(x); mint other(n); return res -= other; } mint operator*(const long long n) const { mint res(x); mint other(n); return res *= other; } mint pow(long long n) const { if (n == 0) return mint(1); mint res = pow(n / 2); res *= res; if (n % 2) res *= *this; return res; } mint inv() const { return pow(mod - 2); } mint& operator/=(const mint& other) { *this *= other.inv(); return *this; } mint operator/(const mint& other) const { mint res(x); return res /= other; } }; int main() { int n; cin >> n; vi a(n); rep(i, n) cin >> a[i]; mint ans = 1; rep(i, n - 1) ans *= min(a[i], a[i + 1]); cout << ans.x << endl; return 0; }