#include using namespace std; using ll = long long; using vi = vector; using vvi = vector; using vll = vector; using vvll = vector; using P = pair; const double eps = 1e-8; const ll MOD = 1000000007; const int INF = INT_MAX / 2; const ll LINF = LLONG_MAX / 2; template bool chmax(T1 &a, const T2 &b) { if(a < b) {a = b; return true;} return false; } template bool chmin(T1 &a, const T2 &b) { if(a > b) {a = b; return true;} return false; } template ostream& operator<<(ostream &os, const pair p) { os << p.first << ":" << p.second; return os; } template ostream &operator<<(ostream &os, const vector &v) { for(int i=0;i<((int)(v.size()));++i) { if(i) os << " "; os << v[i]; } return os; } ll mod_pow(ll x, ll y) { ll res = 1; while(y) { if(y%2) (res *= x) %= MOD; (x *= x) %= MOD; y /= 2; } return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); int n; cin >> n; vll a(n); bool zero = false; for(int i=0;i<(n);++i) cin >> a[i], zero |= a[i] == 0; if(zero) { cout << 0 << endl; return 0; } vll mul(n+1, 1); for(int i=0;i<(n);++i) { mul[i+1] = mul[i] * a[i] % MOD; } vll mulmul(n+1, 1); for(int i=0;i<(n);++i) { mulmul[i+1] = mulmul[i] * mul[i+1] % MOD; } int l = 0, r = 0; ll now = 1; vi v(n); while(l < n) { while(r < n) { if(now * a[r] >= 1e9) break; now *= a[r]; r++; } v[l] = r; now /= a[l]; l++; } ll ans = 1; for(int i=0;i<(n);++i) { ll now = 1; ll tmp = mod_pow(mul[i], v[i] - i); now *= mod_pow(tmp, MOD-2); now %= MOD; now *= mulmul[v[i]]; now %= MOD; now *= mod_pow(mulmul[i], MOD-2); now %= MOD; ans *= now; ans %= MOD; } cout << ans << endl; }