#include <bits/stdc++.h>
using namespace std;
const long long N = 200000, mod = 1e9 + 7;
long long m, p[N + 2], cnt[N + 2], total = 1, ans = 1;
long long binpow(long long n, long long k) {
  long long ans = 1;
  while (k) {
    if (k & 1) ans = (ans * n) % mod;
    n = (n * n) % mod;
    k >>= 1;
  }
  return ans;
}
signed main() {
  cin >> m;
  for (long long i = 1; i <= m; i++) {
    cin >> p[i];
    cnt[p[i]]++;
    ans = (ans * p[i]) % mod;
  }
  long long t1 = 0, t2 = 0;
  for (long long i = 1; i <= N; i++) {
    if (cnt[i]) {
      if (cnt[i] % 2 == 0) {
        t1++;
      }
      t2++;
    }
  }
  if (t1 == t2) {
    long long ans = 1;
    for (long long i = 1; i <= N; i++) {
      if (cnt[i]) {
        ans = (ans * binpow(i, cnt[i] / 2)) % mod;
        long long tmp = cnt[i] + 1;
        total = (total * tmp) % (mod - 1);
      }
    }
    ans = binpow(ans, total);
    return cout << ans, 0;
  }
  bool ok = 1;
  for (long long i = 1; i <= N; i++) {
    if (cnt[i]) {
      long long tmp = cnt[i] + 1;
      if (tmp % 2 == 0 && ok) tmp /= 2, ok = 0;
      total = (total * tmp) % (mod - 1);
    }
  }
  ans = binpow(ans, total);
  cout << ans;
}
