#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL MOD = 1000000007;
const int N = 1000000 + 5;
LL ksm(LL a, LL b) {
LL res = 1;
while (b) {
if (b & 1) res = res * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return res;
}
LL inv(LL x) {
return ksm(x, MOD - 2);
}
int n, cnt, f[N], p[N], s[N];
int vis[N], hav[N], num[N];
void init() {
s[1] = 1;
for (int i = 2; i < N; i++) {
if (!f[i]) p[++cnt] = i, s[i] = i;
for (int j = 1; j <= cnt; j++) {
if (i * p[j] >= N) break;
f[i * p[j]] = 1;
s[i * p[j]] = p[j];
if (i % p[j] == 0)break;
}
}
}
int main(void) {
freopen("pingfang.in", "r", stdin);
freopen("pingfang.out", "w", stdout);
init();
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
LL x;
scanf("%lld", &x);
int tot = 0;
while (x != 1) {
if (!vis[s[x]])
hav[++tot] = s[x];
vis[s[x]]++;
x /= s[x];
}
for (int j = 1; j <= tot; j++) {
if (vis[hav[j]] & 1) num[hav[j]]++;
vis[hav[j]] = 0;
}
}
LL ans = 1;
for (int i = 1; i <= cnt; i++) {
if(!num[p[i]]) continue;
ans = ans * ksm(p[i], min(num[p[i]], n - num[p[i]])) % MOD;
}
printf("%lld\n", ans);
return 0;
}