#include <bits/stdc++.h>
using namespace std;
const int oo = 1e9 + 7;
const int maxn = 2e5 + 7;
const clock_t begin_time = clock();
int n, a[maxn], g;
long long res, cur, pre[maxn], suf[maxn];
long long sum = 1;
pair<long long, long long> b[maxn];
void nhap() {
  scanf("%d", &n);
  for (int i = (1), _b = (n); i <= _b; ++i) {
    scanf("%d", &a[i]);
  }
}
inline long long powx(int x, long long y) {
  long long ret = 1;
  for (long long t = y; t > 0; t >>= 1) {
    if (t & 1) ret = (1LL * ret * x) % oo;
    x = 1LL * x * x % oo;
  }
  return ret;
}
void solve() {
  sort(a + 1, a + n + 1);
  for (int i = (1), _b = (n); i <= _b; ++i)
    if (a[i] != a[i - 1]) {
      b[++g].first = 1;
      b[g].second = a[i];
    } else
      b[g].first++;
  if (g == 1) {
    printf("%I64d",
           powx(b[1].second, (1LL * b[1].first * (b[1].first + 1)) / 2));
    return;
  }
  pre[0] = suf[g + 1] = 1;
  for (int i = (1), _b = (g); i <= _b; ++i)
    pre[i] = 1LL * pre[i - 1] * (b[i].first + 1) % (oo - 1);
  for (int i = (g), _b = (1); i >= _b; --i)
    suf[i] = 1LL * suf[i + 1] * (b[i].first + 1) % (oo - 1);
  res = 1;
  for (int i = (1), _b = (g); i <= _b; ++i) {
    for (int j = (1), _b = (b[i].first); j <= _b; ++j) {
      cur = powx(b[i].second, j);
      res = (1LL * res * powx(cur, (pre[i - 1] * suf[i + 1]) % (oo - 1))) % oo;
    }
  }
  printf("%I64d", res);
}
void print() {}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  nhap();
  solve();
  print();
}
