#line 1 "template/f.h" #include using namespace std; /* --- PBDS, ref: https://codeforces.com/blog/entry/11080 --- */ #include #include using namespace __gnu_pbds; template using IndexSet = tree, rb_tree_tag, tree_order_statistics_node_update>; template using IndexMultiset = tree, rb_tree_tag, tree_order_statistics_node_update>; /* --- CUSTOM HASH, ref: https://codeforces.com/blog/entry/62393 --- */ struct MyHash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; template using us = unordered_set; template using um = unordered_map; using ll = long long; using ld = long double; using PL = pair; using P = pair; template using minheap = priority_queue, greater>; template using maxheap = priority_queue; #define overload5(a, b, c, d, e, name, ...) name #define overload4(a, b, c, d, name, ...) name #define overload3(a, b, c, name, ...) name #define rep1(n) for(ll i=0;i(a);) #define rrep4(i, a, b, c) for(ll i=(a)+((b)-(a)-1)/(c)*(c);i>=(a);i-=c) #define rrep(...) overload4(__VA_ARGS__,rrep4,rrep3,rrep2,rrep1)(__VA_ARGS__) #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() #define sm(...) accumulate(all(__VA_ARGS__),0LL) #define CASE ll _t; cin >> _t; rep(tc, 1, _t + 1) #define YESNO(yes, no)void yes(bool i=1){cout<<(i?#yes:#no)<<'\n';}void no(){cout<<(#no)<<'\n';} YESNO(Yes, No) YESNO(YES, NO) ll fast_exp(ll x, ll t, ll mod) { if (!t)return 1; x %= mod; ll r = fast_exp(x, t / 2, mod); (r *= r) %= mod; if (t % 2)(r *= x) %= mod; return r; } ll popcnt(ll a) { return __builtin_popcountll(a); } template void unique(T &a) { sort(all(a)); a.erase(unique(all(a)), end(a)); } template auto press(const T &a) { vector, ll>> ans; for (auto &&x: a) { if (ans.empty() || ans.back().first != x) ans.emplace_back(x, 1); else ans.back().second++; } return ans; } template bool chmin(T &a, const T &b) { if (a <= b)return 0; a = b; return 1; } template bool chmin(T &a, const U &b) { return chmin(a, (T) b); } template bool chmax(T &a, const T &b) { if (a >= b)return 0; a = b; return 1; } template bool chmax(T &a, const U &b) { return chmax(a, (T) b); } template ostream &operator<<(ostream &os, pair &p) { os << p.first << " " << p.second; return os; } template istream &operator>>(istream &is, pair &p) { is >> p.first >> p.second; return is; } template ostream &operator<<(ostream &os, vector &v) { for (auto it = v.begin(); it != v.end();) { os << *it << ((++it) != v.end() ? " " : ""); } return os; } template istream &operator>>(istream &is, vector &v) { for (T &e: v)is >> e; return is; } struct FastIO { FastIO() { cin.tie(nullptr)->sync_with_stdio(0); fixed(cout).precision(20); } }; namespace Sarievo { const int MOD7 = 1000000007; const int MOD3 = 998244353; const ll dx[]{+0, +1, +0, -1, +1, +1, -1, -1}; const ll dy[]{+1, +0, -1, +0, +1, -1, -1, +1}; const ll INF64 = 0x1fffffffffffffff; } // namespace Sarievo using namespace Sarievo; #line 1 "misc/modint.h" template struct modint { private: unsigned int x; static constexpr unsigned int umod() { return m; } public: static modint raw(int v) { modint ret; ret.x = v; return ret; } constexpr modint() : x(0) {} constexpr modint(int y) { int v = y % m; if (v < 0) v += m; x = (unsigned int) v; } constexpr modint(long long y) { long long v = y % (long long) m; if (v < 0) v += m; x = (unsigned int) v; } constexpr modint(unsigned int y) { x = (unsigned int) (y % umod()); } modint &operator++() { x++; if (x == umod()) x = 0; return *this; } modint &operator--() { if (x == 0) x = umod(); x--; return *this; } modint operator++(int) { modint ret = *this; ++*this; return ret; } modint operator--(int) { modint ret = *this; --*this; return ret; } modint &operator+=(const modint &p) { if ((x += p.x) >= umod()) x -= umod(); return *this; } modint &operator-=(const modint &p) { if ((x -= p.x) >= umod()) x += umod(); return *this; } modint &operator*=(const modint &p) { unsigned long long y = x; y *= p.x; x = (unsigned int) (y % umod()); return *this; } modint &operator/=(const modint &p) { return *this *= p.inv(); } modint operator+() const { return *this; } modint operator-() const { return modint() - *this; } modint pow(long long n) const { modint ret(1), mul = *this; while (n) { if (n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } modint inv() const { long long a = x, b = m, u = 1, v = 0; while (b) { long long t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return modint(u); } friend modint operator+(const modint &l, const modint &r) { return modint(l) += r; } friend modint operator-(const modint &l, const modint &r) { return modint(l) -= r; } friend modint operator*(const modint &l, const modint &r) { return modint(l) *= r; } friend modint operator/(const modint &l, const modint &r) { return modint(l) /= r; } friend bool operator==(const modint &l, const modint &r) { return l.x == r.x; } friend bool operator!=(const modint &l, const modint &r) { return l.x != r.x; } friend ostream &operator<<(ostream &os, const modint &p) { return os << p.val(); } friend istream &operator>>(istream &is, modint &a) { long long t; is >> t; a = modint(t); return (is); } static constexpr int get_mod() { return m; } [[nodiscard]] int val() const { return (int) x; } }; #line 3 "main.cpp" using mint = modint; signed main() { ll n; cin >> n; vector a(n); cin >> a; mint ans = 1; rep(n - 1) { ans *= min(a[i], a[i + 1]); } cout << ans << '\n'; }