#include #if __has_include() #include std::ostream &operator<<(std::ostream &os, const atcoder::modint998244353 &v) { os << v.val(); return os; } std::istream &operator>>(std::istream &is, atcoder::modint998244353 &v) { long long x; is >> x; v = x; return is; } std::ostream &operator<<(std::ostream &os, const atcoder::modint1000000007 &v) { os << v.val(); return os; } std::istream &operator>>(std::istream &is, atcoder::modint1000000007 &v) { long long x; is >> x; v = x; return is; } #endif using namespace std; using ll = long long; using pll = pair; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) #define rrep(i, s, t) for (ll i = (ll)(t) - 1; i >= (ll)(s); i--) #define all(x) begin(x), end(x) #define TT template TT using vec = vector; TT using vvec = vec>; TT using vvvec = vec>; TT using minheap = priority_queue, greater>; TT using maxheap = priority_queue; template bool chmin(T1 &x, T2 y) { return x > y ? (x = y, true) : false; } template bool chmax(T1 &x, T2 y) { return x < y ? (x = y, true) : false; } struct io_setup { io_setup() { ios::sync_with_stdio(false); std::cin.tie(nullptr); cout << fixed << setprecision(15); } } io_setup; template ostream &operator<<(ostream &os, const pair &p) { os << p.first << " " << p.second; return os; } TT ostream &operator<<(ostream &os, const vec &v) { for (size_t i = 0; i < v.size(); i++) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } template ostream &operator<<(ostream &os, const array &v) { for (size_t i = 0; i < n; i++) { os << v[i] << (i + 1 != n ? " " : ""); } return os; } template std::ostream &operator<<(ostream &os, const vvec &v) { for (size_t i = 0; i < v.size(); i++) { os << v[i] << (i + 1 != v.size() ? "\n" : ""); } return os; } TT istream &operator>>(istream &is, vec &v) { for (size_t i = 0; i < v.size(); i++) { is >> v[i]; } return is; } #if __has_include() #include #else #define dbg(...) true #define DBG(...) true #endif // 動的mod : template を消して、上の方で変数modを宣言 template struct modint { using mm = modint; uint32_t x; modint() : x(0) {} TT modint(T a = 0) : x((ll(a) % mod + mod)) { if (x >= mod) x -= mod; } friend mm operator+(mm a, mm b) { a.x += b.x; if (a.x >= mod) a.x -= mod; return a; } friend mm operator-(mm a, mm b) { a.x -= b.x; if (a.x >= mod) a.x += mod; return a; } //+と-だけで十分な場合、以下は省略して良いです。 friend mm operator*(mm a, mm b) { return (uint64_t)(a.x) * b.x; } friend mm operator/(mm a, mm b) { return a * b.inv(); } friend mm &operator+=(mm &a, mm b) { return a = a + b; } friend mm &operator-=(mm &a, mm b) { return a = a - b; } friend mm &operator*=(mm &a, mm b) { return a = a * b; } friend mm &operator/=(mm &a, mm b) { return a = a * b.inv(); } mm inv() const { return pow(mod - 2); } mm pow(ll y) const { mm res = 1; mm v = *this; while (y) { if (y & 1) res *= v; v *= v; y /= 2; } return res; } friend istream &operator>>(istream &is, mm &a) { ll t; cin >> t; a = mm(t); return is; } friend ostream &operator<<(ostream &os, mm a) { return os << a.x; } bool operator==(mm a) { return x == a.x; } bool operator!=(mm a) { return x != a.x; } bool operator<(const mm &a) const { return x < a.x; } }; using modint998244353 = modint<998244353>; using modint1000000007 = modint<1'000'000'007>; /* @brief modint */ using mint = modint998244353; int main() { ll n; cin >> n; vec A(n); rep(i, 0, n) cin >> A[i]; mint res = 1; rep(i, 0, n - 1) res *= min(A[i], A[i + 1]); cout << res << endl; }