import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.stdlib; immutable long mod = 10 ^^ 9 + 7; void main() { auto N = readln.chomp.to!int; auto A = readln.split.map!(to!long).array; if (A.map!(a => a == 0).any) { writeln(0); return; } long ans = 1; foreach (a; A.split(0)) { ans = ans * solve(a.array) % mod; } ans.writeln; } long solve(long[] A) { if (A.empty) return 1; int N = A.length.to!int; long tmp = 1; long ans = 1; auto imos = new long[](N+1); auto len = new long[](N+1); for (int i = 0, j = 0; i < N; ++i) { if (i > 0) tmp /= A[i-1]; while (j < N && tmp * A[j] < 10^^9) { tmp *= A[j++]; } if (i > 0) imos[i-1] -= 1; imos[j-1] += 1; len[i] = j - i; } foreach_reverse (i; 1..N) imos[i-1] += imos[i]; foreach_reverse(i; 1..N) imos[i-1] += imos[i] - len[i]; foreach (i; 0..N) ans = ans * powmod(A[i], imos[i], mod) % mod; return ans; } long powmod(long a, long x, long m) { long ret = 1; while (x) { if (x % 2) ret = ret * a % m; a = a * a % m; x /= 2; } return ret; }