#include #define rep(i,n) for(int i=0;i<(int)(n);i++) using namespace std; using ll = long long ; using P = pair ; using pll = pair; constexpr ll INF = 1e9; constexpr long long LINF = 1e17; constexpr int MOD = 1000000007; constexpr double PI = 3.14159265358979323846; ll n = 100005; vector a(n); long long modpow(long long x, long long n) { long long ret = 1; while (n > 0) { if (n & 1) ret = (ret * x) % MOD; x = (x * x) % MOD; n >>= 1; } return ret; } ll dfs(ll l,ll r){ if(l==r) return 1; if(l+1==r) return a[l]; ll p1 = dfs(l,(l+r)/2); ll p2 = dfs((l+r)/2,r); ll res = (p1 * p2)%MOD; vector F,L; ll now = 1; ll m = (l+r)/2; while(1){ if(m>=r) break; now *= a[m]; m ++; if(now < INF) L.push_back(now); else break; } now = 1; m = ((l+r)/2) - 1; while(1){ if(m cnt(L.size(),0); rep(i,F.size()){ ll left = -1,right = L.size(); while(right - left > 1){ ll mid = (left + right)/2; if(F[i]*L[mid]=0;i--){ ll now = cnt[i]; if(i==L.size()-1) cnt[i] = now + point; else cnt[i] = now + cnt[i+1] + point; point += now; } rep(i,L.size()){ res = (res * modpow(a[i+(l+r)/2],cnt[i]))%MOD; } /* rep(i,L.size()){ cout << cnt[i] << " " ; } cout << endl; */ return res; } int main(){ cin >> n; a.resize(n); rep(i,n) cin >> a[i]; cout << dfs(0,n) << endl; return 0; }