#include <bits/stdc++.h>
using namespace std;
int m;
int ppow(long long p, long long pw) {
  long long res = 1;
  p %= 1000000007;
  while (pw > 0) {
    if (pw % 2) {
      res *= p;
      res %= 1000000007;
    }
    p *= p;
    p %= 1000000007;
    pw /= 2;
  }
  return res;
}
int main() {
  cin >> m;
  vector<int> inps(m);
  long long res = 1;
  for (int i = 0; i < m; i++) scanf("%d", &inps[i]);
  sort(inps.begin(), inps.end());
  vector<int> ps(m), ns(m);
  int c = 0;
  int ind = 0;
  while (c < inps.size()) {
    int nn = 1;
    while (c < inps.size() - 1 && inps[c + 1] == inps[c]) {
      c++;
      nn++;
    }
    ps[ind] = inps[c];
    c++;
    ns[ind] = nn;
    ind++;
  }
  int n = ind;
  vector<long long> prods(n, 1);
  vector<long long> p1(n, 1);
  vector<long long> p2(n, 1);
  p1[0] = (ns[0] + 1);
  for (int i = 1; i < n; i++) {
    p1[i] = p1[i - 1] * (ns[i] + 1);
    while (p1[i] > 1000000007) p1[i] = p1[i] / 1000000007 + p1[i] % 1000000007;
  }
  p2[n - 1] = (ns[n - 1] + 1);
  for (int i = n - 2; i >= 0; i--) {
    p2[i] = p2[i + 1] * (ns[i] + 1);
    while (p2[i] > 1000000007) p2[i] = p2[i] / 1000000007 + p2[i] % 1000000007;
  }
  for (int i = 0; i < n; i++) prods[i] = 1;
  if (n > 1) {
    prods[0] = p2[1];
    prods[n - 1] = p1[n - 2];
  }
  for (int i = 1; i < n - 1; i++) {
    prods[i] = p1[i - 1] * p2[i + 1];
    while (prods[i] > 1000000007)
      prods[i] = prods[i] / 1000000007 + prods[i] % 1000000007;
  }
  for (int i = 0; i < n; i++) {
    prods[i] = ppow(ps[i], prods[i]);
  }
  for (int i = 0; i < n; i++) {
    long long pp = (((long long)ns[i]) * (ns[i] + 1)) / 2;
    while (pp > 1000000007) {
      pp = pp / 1000000007 + pp % 1000000007;
    }
    res *= ppow(prods[i], pp);
    res %= 1000000007;
  }
  cout << res;
}
