#include <bits/stdc++.h>
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    std::cerr << v << " ";
    return *this;
  }
} dbg;
long long bigmod(long long sonkha, long long ghat, long long vag_const) {
  long long vag_shesh = 1;
  while (ghat > 0) {
    if (ghat % 2 == 1) {
      vag_shesh = (vag_shesh * sonkha) % vag_const;
    }
    ghat /= 2;
    sonkha = (sonkha * sonkha) % vag_const;
  }
  return vag_shesh;
}
long long inverse_mod(long long bivajok, long long vag_const) {
  return bigmod(bivajok, vag_const - 2, vag_const);
}
using namespace std;
map<long long, long long> mpp, indx;
long long prod = 1, ans = 1, fw[200005], bw[200005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, m, y, k;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> m;
    mpp[m]++;
  }
  m = 0;
  for (auto& x : mpp) {
    prod *= (x.second + 1);
    prod %= (1000000007 - 1);
    fw[m] = prod;
    indx[x.first] = m++;
  }
  prod = 1;
  for (map<long long, long long>::reverse_iterator x = mpp.rbegin();
       x != mpp.rend(); x++) {
    prod *= ((x->second) + 1);
    prod %= (1000000007 - 1);
    bw[indx[(x->first)]] = prod;
  }
  for (auto& x : mpp) {
    y = x.second;
    k = y++;
    if (y & 1LL)
      k /= 2;
    else
      y /= 2;
    y = (k * y) % (1000000007 - 1);
    if (indx[x.first] > 0) y = (fw[indx[x.first] - 1] * y) % (1000000007 - 1);
    if (indx[x.first] + 1 < m)
      y = (bw[indx[x.first] + 1] * y) % (1000000007 - 1);
    ans *= (bigmod(x.first, y, 1000000007));
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}
