#ifndef LOCAL #include using namespace std; #define debug(...) (void(0)) #else #include "algo/debug.h" #endif #include using mint = atcoder::modint1000000007; void solve() { int N; cin >> N; vector A(N); for (int i = 0; i < N; i++) { cin >> A[i]; if (A[i] == 0) { cout << 0 << endl; return; } } vector> thr(N + 1); int j = 0; __uint128_t mul = 1; constexpr __uint128_t inf = 1e9; for (int i = 0; i < N; i++) { while (j < N && mul * A[j] < inf) mul *= A[j++]; // [i, j) < 10^9 thr[j].push_back(i); mul /= A[i]; } vector pref(N + 1, 1); for (int i = 0; i < N; i++) pref[i + 1] = pref[i] * A[i]; mint ans = 1; mint ps = 1; int cnt = 0; for (int i = 0; i < N; i++) { cnt++; ps *= mint(A[i]).pow(cnt); for (int j : thr[i]) { mint t = pref[i + 1] / pref[j]; ps /= t; cnt--; } ans *= ps; } cout << ans.val() << endl; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int tt = 1; // std::cin >> tt; while (tt--) { solve(); } }