#include <bits/stdc++.h>
using namespace std;
template <class X, class Y>
void minimize(X &x, const Y &y) {
  if (x > y) x = y;
}
template <class X, class Y>
void maximize(X &x, const Y &y) {
  if (x < y) x = y;
}
const int mod = (int)1e9 + 7;
int pw(int x, int k) {
  int res = 1;
  int mul = x;
  while (k > 0) {
    if (k & 1) res = 1LL * res * mul % mod;
    mul = 1LL * mul * mul % mod;
    k >>= 1;
  }
  return (res);
}
int cnt[200200];
void process(void) {
  int n;
  scanf("%d", &n);
  for (int love = 0, _n = (n); love < _n; love = love + 1) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
  }
  bool haveOdd = false;
  for (int i = 0, _n = (200200); i < _n; i = i + 1)
    if (cnt[i] % 2 != 0) haveOdd = true;
  if (haveOdd) {
    bool firstOdd = true;
    int mul = 1;
    for (int i = 0, _n = (200200); i < _n; i = i + 1)
      if (cnt[i] > 0) {
        if (firstOdd && cnt[i] % 2 != 0) {
          mul = 1LL * mul * ((cnt[i] + 1) / 2) % (mod - 1);
          firstOdd = false;
        } else
          mul = 1LL * mul * (cnt[i] + 1) % (mod - 1);
      }
    int res = 1;
    for (int i = 0, _n = (200200); i < _n; i = i + 1)
      if (cnt[i] > 0)
        res = 1LL * res * pw(i, 1LL * mul * cnt[i] % (mod - 1)) % mod;
    printf("%d\n", res);
  } else {
    int mul = 1;
    for (int i = 0, _n = (200200); i < _n; i = i + 1)
      if (cnt[i] > 0) mul = 1LL * mul * (cnt[i] + 1) % (mod - 1);
    int res = 1;
    for (int i = 0, _n = (200200); i < _n; i = i + 1)
      if (cnt[i] > 0)
        res = 1LL * res * pw(i, 1LL * cnt[i] / 2 * mul % (mod - 1)) % mod;
    printf("%d\n", res);
  }
}
int main(void) {
  process();
  return 0;
}
