#include using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef long double ld; typedef pair P; typedef pair PL; constexpr int mod = 1e9 + 7; constexpr int INF = 1e9; ll mod_pow(ll x, ll n, ll mod){ if(n == 0)return 1; ll res = mod_pow(x*x%mod,n/2,mod); if(n&1) res = res * x % mod; return res; } int main() { int n; cin >> n; vector a(n); rep(i,n) cin >> a[i]; vector cnt(n, 0); ll res = 1; int r = 0; ll now = 1; for (int l = 0; l < n; l++) { while (r < n && now * a[r] < INF) { now *= a[r]; r++; } int len = r - l; for (int i = l; i < r; i++) { cnt[i] += len; len--; } now /= a[l]; } for (int i = 0; i < n; i++) { res *= mod_pow(a[i], cnt[i], mod); res %= mod; } cout << res << endl; return 0; }