#include <bits/stdc++.h>
using namespace std;
long long m, cnt[200005], ans = 1, pro = 1, prefix[200005], suffix[200005], a,
                          b;
vector<long long> pr;
long long pw(long long val, long long mul) {
  if (mul == 0) return 1;
  if (mul == 1) return val;
  long long tmp = pw(val, mul / 2) % 1000000007;
  if (mul % 2)
    return (((tmp * tmp) % 1000000007) * val) % 1000000007;
  else
    return (tmp * tmp) % 1000000007;
}
long long ahihi(long long val) { return val * (val + 1) / 2; }
signed main() {
  long long x;
  cin >> m;
  for (long long i = 0; i < 200002; i++) cnt[i] = 1;
  pr.push_back(-1);
  while (m--) {
    cin >> x;
    if (cnt[x] == 1) pr.push_back(x);
    cnt[x]++;
  }
  prefix[0] = 1;
  suffix[pr.size()] = 1;
  for (long long i = 1; i < pr.size(); i++) {
    prefix[i] = (prefix[i - 1] * cnt[pr[i]]) % (1000000007 - 1);
  }
  for (long long i = pr.size() - 1; i > 0; i--) {
    suffix[i] = (suffix[i + 1] * cnt[pr[i]]) % (1000000007 - 1);
  }
  for (long long i = 1; i < pr.size(); i++) {
    x = pw(pr[i], ahihi(cnt[pr[i]] - 1));
    x = pw(x, (prefix[i - 1] * suffix[i + 1]) % (1000000007 - 1));
    ans *= x;
    ans %= 1000000007;
  }
  cout << ans;
}
