#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
int primes[N];
long long fast_power(long long base, long long power) {
  long long result = 1;
  while (power > 0) {
    if (power % 2 == 1) {
      result = (result * base) % 1000000007;
    }
    base = (base * base) % 1000000007;
    power = power / 2;
  }
  return result;
}
long long fun(long long x) {
  long long ans = 1;
  for (int i = 1; i <= primes[x] + 1; i++)
    ans = ((ans % 1000000007) * (fast_power(x, i) % 1000000007)) % 1000000007;
  return ans;
}
int n, k;
string s;
int main() {
  cin >> n;
  long long cnt = 1;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    primes[x]++;
  }
  bool flag = false;
  for (int i = 0; i < N; i++) {
    if (!primes[i]) continue;
    long long t2 = primes[i] + 1;
    if (t2 % 2 == 0 && !flag) t2 /= 2, flag = 1;
    cnt = (cnt * (t2 % (1000000007 - 1))) % (1000000007 - 1);
  }
  long long ans = 1;
  for (int i = 0; i < N; i++) {
    if (!primes[i]) continue;
    long long t2 = primes[i];
    if (!flag) t2 /= 2;
    ans = ans * (fast_power(i, t2 * cnt) % 1000000007) % 1000000007;
  }
  cout << ans;
}
