#include <bits/stdc++.h>
using namespace std;
const double g = 10.0, eps = 1e-9;
const int N = 200000 + 10, maxn = 2000 + 10, inf = 0x3f3f3f3f,
          INF = 0x3f3f3f3f3f3f3f3f;
long long a[N], num[N], inv[N], per[N], suf[N];
long long quick(long long a, long long b, long long c) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % c;
    a = a * a % c;
    b >>= 1;
  }
  return ans;
}
int main() {
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &a[i]);
    num[a[i]]++;
  }
  sort(a, a + m);
  m = unique(a, a + m) - a;
  long long ans = 1, sum = 1;
  for (int i = 0; i < m; i++) sum = sum * (num[a[i]] + 1) % (1000000007 - 1);
  per[0] = 1;
  for (int i = 1; i < m; ++i)
    per[i] = per[i - 1] * (num[a[i - 1]] + 1) % (1000000007 - 1);
  suf[m] = 1;
  for (int i = m - 1; i > 0; --i)
    suf[i] = suf[i + 1] * (num[a[i]] + 1) % (1000000007 - 1);
  for (int i = 0; i < m; i++) {
    long long te = per[i] * suf[i + 1] % (1000000007 - 1);
    long long now = 1;
    for (int j = 1; j <= num[a[i]]; j++) {
      now = now * a[i] % 1000000007;
      ans = ans * quick(now, te, 1000000007) % 1000000007;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
