#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
int n;
int ans;
int p[200200];
long long binpow(long long x, long long y, long long mod) {
  if (y == 0) return 1 % mod;
  if (y % 2 == 1) return binpow(x, y - 1, mod) * 1ll * x % mod;
  return binpow(x * 1ll * x % mod, y / 2, mod);
}
int main() {
  ans = 1;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }
  sort(p, p + n);
  long long c = 1;
  long long ans = 1;
  for (int i = 0; i < n;) {
    int j = i;
    while (i < n && p[j] == p[i]) i++;
    ans = binpow(ans, i - j + 1, mod);
    long long cur = binpow(p[j], (i - j + 1) * 1ll * (i - j) / 2, mod);
    ans = ans * 1ll * binpow(cur, c, mod) % mod;
    c = (c * 1ll * (i - j) + c) % (mod - 1);
  }
  cout << ans << endl;
  return 0;
}
