#line 1 "1.declarations/template/template.h" #include using namespace std; using ll = long long; using ld = long double; using PL = pair; using P = pair; #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 CASE ll _t; cin >> _t; rep(tc, 1, _t + 1) #define YESNO(yes, no)void yes(bool b=1){cout<<(b?#yes:#no)<<'\n';}void no(bool b=1){yes(!b);} YESNO(Yes, No) YESNO(YES, NO) 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 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); } ll popcnt(ll a) { return __builtin_popcountll(a); } ll pow(ll x, ll t, ll m) { if (!t) return 1; x %= m; ll r = pow(x, t / 2, m); (r *= r) %= m; if (t % 2)(r *= x) %= m; return r; } 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 IO { IO() { std::cin.tie(nullptr)->sync_with_stdio(0); fixed(std::cout).precision(20); } } io; namespace Sarievo { const int MOD7 = 1000000007; const int MOD3 = 998244353; const ll INF64 = 0x1fffffffffffffff; const long double pi = 3.14159265358979323; const long double eps = 1e-7; const ll dx[]{+0, +1, +0, -1, +1, +1, -1, -1}; const ll dy[]{+1, +0, -1, +0, +1, -1, -1, +1}; const string ASCII = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const string ascii = "abcdefghijklmnopqrstuvwxyz"; const string NUM = "0123456789"; } // namespace Sarievo using namespace Sarievo; #line 2 "main.cpp" template struct MInt { private: unsigned int x; public: static MInt raw(int v) { MInt ret; ret.x = v; return ret; } constexpr MInt() : x(0) {} constexpr MInt(int y) { int v = y % m; if (v < 0) v += m; x = (unsigned int) v; } constexpr MInt(long long y) { long long v = y % (long long) m; if (v < 0) v += m; x = (unsigned int) v; } constexpr MInt(unsigned int y) { x = (unsigned int) (y % get_mod()); } MInt &operator++() { x++; if (x == get_mod()) x = 0; return *this; } MInt &operator--() { if (x == 0) x = get_mod(); x--; return *this; } MInt operator++(int) { MInt ret = *this; ++*this; return ret; } MInt operator--(int) { MInt ret = *this; --*this; return ret; } MInt &operator+=(const MInt &p) { if ((x += p.x) >= get_mod()) x -= get_mod(); return *this; } MInt &operator-=(const MInt &p) { if ((x -= p.x) >= get_mod()) x += get_mod(); return *this; } MInt &operator*=(const MInt &p) { unsigned long long y = x; y *= p.x; x = (unsigned int) (y % get_mod()); return *this; } MInt &operator/=(const MInt &p) { return *this *= p.inv(); } MInt operator+() const { return *this; } MInt operator-() const { return MInt() - *this; } MInt pow(long long n) const { MInt ret(1), mul = *this; while (n) { if (n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } MInt 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 MInt(u); } friend MInt operator+(const MInt &l, const MInt &r) { return MInt(l) += r; } friend MInt operator-(const MInt &l, const MInt &r) { return MInt(l) -= r; } friend MInt operator*(const MInt &l, const MInt &r) { return MInt(l) *= r; } friend MInt operator/(const MInt &l, const MInt &r) { return MInt(l) /= r; } friend bool operator==(const MInt &l, const MInt &r) { return l.x == r.x; } friend bool operator!=(const MInt &l, const MInt &r) { return l.x != r.x; } friend istream &operator>>(istream &is, MInt &a) { long long t; is >> t; a = MInt(t); return (is); } friend ostream &operator<<(ostream &os, const MInt &p) { return os << p.val(); } static constexpr int get_mod() { return m; } [[nodiscard]] int val() const { return (int) x; } }; void solve() { using mint = MInt; 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'; } signed main() { solve(); }