#include <bits/stdc++.h>
using namespace std;
int f[200021];
int lleft[200021];
int rright[200022];
const int mod = (int)1e9 + 7;
int power(int base, int expo) {
  int ret = 1;
  int x = base;
  while (expo) {
    if (expo & 1) ret = ((long long)ret * x) % mod;
    x = ((long long)x * x) % mod;
    expo /= 2;
  }
  return ret;
}
long long calc(int f) { return (((long long)f * (f + 1)) / 2) % (mod - 1); }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, i, j, l, r;
  cin >> n;
  for (i = 0; i < n; ++i) {
    cin >> l;
    f[l]++;
  }
  long long product = 1;
  lleft[0] = 1;
  rright[200001] = 1;
  for (i = 1; i <= 200000; ++i)
    lleft[i] = ((long long)lleft[i - 1] * (f[i - 1] + 1)) % (mod - 1);
  for (i = 200000; i >= 0; --i)
    rright[i] = ((long long)rright[i + 1] * (f[i + 1] + 1)) % (mod - 1);
  long long ans = 1;
  for (i = 1; i <= 200000; ++i) {
    if (!f[i]) continue;
    ans *=
        power(i, ((((long long)rright[i] * lleft[i]) % (mod - 1) * calc(f[i])) %
                  (mod - 1)));
    ans %= mod;
  }
  cout << ans;
  return 0;
}
