#include #include #include #include #include #include #include using namespace std; typedef long long ll; const ll MOD = 1000000007; int N; ll A[100000]; vector v; ll inv(ll n){ if(n == 1) return 1; else return MOD-inv(MOD%n)*(MOD/n)%MOD; } template T pow(T a, ll n) { T ans = 1; T tmp = a; for (int i = 0; i <= 60; i++) { ll m = (ll)1 << i; if (m & n) { ans *= tmp; ans %= MOD; } tmp *= tmp; tmp %= MOD; } return ans; } ll ans = 1; ll th = 1e9; void calc(){ ll tmp = 1; ll cur = 1; int sz = v.size(); int r = 0; for(int l = 0; l < sz; l++){ if(l > 0) { tmp /= v[l-1]; cur *= inv(pow(v[l-1], r-l+1)); cur %= MOD; } while(tmp*v[r] < th && r < sz){ tmp*= v[r]; cur *= tmp; cur %= MOD; r++; } ans *= cur; ans %= MOD; } } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; cin >> N; for(int i = 0; i < N; i++) cin >> A[i]; for(int i = 0; i < N; i++){ if(A[i] != 0) v.push_back(A[i]); if(A[i] == 0){ cout << 0 << endl; return 0; } } calc(); cout << ans << endl; }