#include <bits/stdc++.h>
using namespace std;
int primes[200010];
const int mod = 1e9 + 7;
int b[200010];
int pre[200010];
int suf[200010];
int fastpow(int a, int b, int c) {
  int res = 1;
  while (b) {
    if (b & 1) {
      res = 1LL * res * a % c;
    }
    b >>= 1;
    a = 1LL * a * a % c;
  }
  return res;
}
int main() {
  int n;
  scanf("%d", &n);
  int val;
  memset(primes, 0, sizeof(primes));
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &val);
    ++primes[val];
  }
  b[0] = 1;
  for (int i = 1; i <= 200000; ++i) {
    b[i] = b[i - 1] * 2;
    if (b[i] >= mod) {
      b[i] -= mod;
    }
  }
  pre[1] = 1;
  for (int i = 2; i <= 200000; ++i) {
    pre[i] = 1LL * pre[i - 1] * (1 + primes[i]) % (mod - 1);
  }
  suf[200000] = 1;
  for (int i = 199999; i >= 1; --i) {
    suf[i] = 1LL * suf[i + 1] * (1 + primes[i]) % (mod - 1);
  }
  int ans = 1;
  for (int i = 2; i <= 200000; ++i) {
    if (primes[i]) {
      int ep = 1;
      if (primes[i] & 1) {
        ep = 1LL * (primes[i] + 1) / 2 * primes[i] % (mod - 1);
      } else {
        ep = 1LL * primes[i] / 2 * (primes[i] + 1) % (mod - 1);
      }
      ep = 1LL * ep * suf[i + 1] % (mod - 1) * pre[i - 1] % (mod - 1);
      ans = 1LL * ans * fastpow(i, ep, mod) % mod;
    }
  }
  printf("%d\n", ans);
  return 0;
}
