#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  if (x == 0) {
    return y;
  } else
    return gcd(x % y, y);
}
bool prime[10000001];
void SieveOfErat() {
  memset(prime, true, sizeof(prime));
  for (long long p = 2; p * p <= 1000000; p++) {
    if (prime[p] == true) {
      for (long long i = p * 2; i <= 1000000; i += p) prime[i] = false;
    }
  }
}
long long powe(long long a, long long b) {
  long long p = 1;
  while (b) {
    if (b & 1) {
      p *= a;
      p %= 1000000007;
    }
    a *= a;
    a %= 1000000007;
    b = b / 2;
  }
  return p;
}
int main() {
  long long n;
  cin >> n;
  map<long long, long long> m;
  for (long long i = 0; i < n; i++) {
    long long in;
    cin >> in;
    m[in]++;
  }
  long long ans = 1;
  long long d = 1;
  for (map<long long, long long>::iterator it = m.begin(); it != m.end();
       it++) {
    long long p = it->first;
    long long cnt = it->second;
    long long fp = powe(p, ((cnt * (cnt + 1)) / 2) % (1000000007 - 1));
    ans = ((powe(ans, cnt + 1)) * powe(fp, d)) % 1000000007;
    d = (d * (cnt + 1)) % (1000000007 - 1);
  }
  cout << ans << endl;
}
