#include <bits/stdc++.h>
using namespace std;
long long qp(long long a, long long k) {
  a %= 1000000007;
  long long ret = 1;
  while (k) {
    if (k & 1) ret = ret * a % 1000000007;
    a = a * a % 1000000007;
    k >>= 1;
  }
  return ret;
}
int a[200000 + 5], cnt[200000 + 5];
long long pre[200000 + 5], suf[200000 + 5];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  int m = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[m]) a[++m] = a[i];
    cnt[m]++;
  }
  n = m;
  pre[0] = 1;
  for (int i = 1; i <= n; i++)
    pre[i] = pre[i - 1] * (cnt[i] + 1) % (1000000007 - 1);
  suf[n + 1] = 1;
  for (int i = n; i >= 1; i--)
    suf[i] = suf[i + 1] * (cnt[i] + 1) % (1000000007 - 1);
  long long ans = 1;
  for (int i = 1; i <= n; i++)
    ans = ans *
          qp(a[i], 1ll * cnt[i] * (cnt[i] + 1) / 2 % (1000000007 - 1) *
                       pre[i - 1] % (1000000007 - 1) * suf[i + 1] %
                       (1000000007 - 1)) %
          1000000007;
  printf("%lld\n", ans);
  return 0;
}
