#include <bits/stdc++.h>
using namespace std;
const int N = 200005, M = 1000000007;
int cnt[N], a[N];
long long b[N], c[N];
int phi(int x) {
  int ret = x;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      ret -= ret / i;
      while (x % i == 0) {
        x /= i;
      }
    }
  }
  if (x > 1) {
    ret -= ret / x;
  }
  return ret;
}
long long power(int x, long long y, int mod) {
  if (y == 0) return 1;
  long long temp = power(x, y >> 1, mod);
  temp *= temp;
  temp %= mod;
  if (y & 1) {
    temp *= x;
    temp %= mod;
  }
  return temp;
}
int main() {
  int ph = phi(M);
  int n, mx = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    ++cnt[x];
    mx = max(mx, x);
  }
  int sz = 0;
  for (int i = 0; i <= mx; i++) {
    if (cnt[i]) {
      a[sz++] = i;
      if (sz > 1) {
        b[sz - 1] = b[sz - 2] * (cnt[i] + 1);
        b[sz - 1] %= ph;
      } else {
        b[sz - 1] = cnt[i] + 1;
      }
    }
  }
  if (sz == 1) {
    return printf("%lld",
                  power(a[0], (long long)cnt[a[0]] * (cnt[a[0]] + 1) / 2, M)),
           0;
  }
  c[sz - 1] = cnt[a[sz - 1]] + 1;
  for (int i = sz - 2; i >= 0; i--) {
    c[i] = c[i + 1] * (cnt[a[i]] + 1);
    c[i] %= ph;
  }
  long long res = 1;
  for (int i = 0; i < sz; i++) {
    long long po;
    if (i == 0) {
      po = c[1];
    } else if (i == sz - 1) {
      po = b[sz - 2];
    } else {
      po = (b[i - 1] * c[i + 1]) % ph;
    }
    long long temp = (long long)cnt[a[i]] * (cnt[a[i]] + 1) / 2;
    temp = power(a[i], temp, M);
    temp = power(temp, po, M);
    res *= temp;
    res %= M;
  }
  printf("%lld", res);
  return 0;
}
