#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6;
const int mod = 1e9 + 7;
long long mp[maxn];
long long binpow(long long a, long long b, long long c) {
  if (b == 0) return 1;
  long long res = binpow(a, b / 2, c);
  res = (res * res) % c;
  if (b % 2 != 0) res = (res * a) % c;
  return res;
}
int m;
long long p[maxn];
long long ans = 1, cnt = 1, f;
int main() {
  ios_base::sync_with_stdio(false);
  scanf("%d\n", &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%I64d", &p[i]);
    mp[p[i]]++;
  }
  for (int i = 1; i <= m; ++i) {
    if (mp[p[i]] != -1) {
      f = binpow(p[i], (mp[p[i]] + 1) * mp[p[i]] / 2, mod);
      ans = (binpow(ans, mp[p[i]] + 1, mod) * binpow(f, cnt, mod)) % mod;
      cnt = (cnt * (mp[p[i]] + 1)) % (mod - 1);
      mp[p[i]] = -1;
    }
  }
  printf("%I64d", ans);
}
