#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll const mod = 1000000000 + 7;
ll binPow(ll a, ll q) {
  a %= mod;
  if (q == 0) return 1;
  return ((q % 2 == 1 ? a : 1) * binPow(a * a, q / 2)) % mod;
}
int main() {
  int i, j, k;
  int n, m;
  map<int, int> mii;
  cin >> n;
  for (i = 0; i < n; i++) {
    int x;
    cin >> x;
    mii[x]++;
  }
  ll d = 1;
  ll res = 1;
  for (auto pii : mii) {
    ll p = pii.first;
    ll cnt = pii.second;
    ll fp = binPow(p, (cnt + 1) * cnt / 2);
    res = binPow(res, (cnt + 1)) * binPow(fp, d) % mod;
    d = d * (cnt + 1) % (mod - 1);
  }
  cout << res << endl;
  return 0;
}
