#include <bits/stdc++.h>
using namespace std;
long long m, p[200005], k;
pair<long long, long long> s[200005];
long long sl[200005], sr[200005];
const long long mod = 1e9 + 7;
long long powmod(long long a, long long n) {
  if (n == 0) return 1;
  if (n == 1) return a % mod;
  if (n & 1) return (powmod(a, n - 1) * a) % mod;
  a %= mod;
  a *= a;
  a %= mod;
  return powmod(a, n / 2);
}
int main() {
  cin >> m;
  for (int i = 1; i <= m; i++) cin >> p[i];
  sort(p + 1, p + m + 1);
  int cnt = 1;
  for (int i = 2; i <= m; i++) {
    if (p[i] == p[i - 1]) {
      cnt++;
    } else {
      s[++k] = {p[i - 1], cnt};
      cnt = 1;
    }
  }
  s[++k] = {p[m], cnt};
  sl[0] = 1;
  sl[1] = s[1].second + 1;
  for (int i = 2; i <= k; i++) {
    sl[i] = (1LL * sl[i - 1] * (s[i].second + 1)) % (mod - 1);
  }
  sr[k + 1] = 1;
  sr[k] = s[k].second + 1;
  for (int i = k - 1; i; i--) {
    sr[i] = (1LL * sr[i + 1] * (s[i].second + 1)) % (mod - 1);
  }
  long long rs = 1;
  for (int i = 1; i <= k; i++) {
    long long tmp = 1LL * sl[i - 1] * sr[i + 1];
    tmp %= mod - 1;
    for (int j = 1; j <= s[i].second; j++) {
      rs = (rs * powmod(s[i].first, 1LL * j * tmp)) % mod;
    }
  }
  return cout << rs, 0;
}
