#include <bits/stdc++.h>
using namespace std;
long long A[200005];
long long fast_pow(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
int main() {
  long long div = 1, num = 1;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    num = (num * A[i]) % 1000000007;
  }
  sort(A, A + n);
  int idx = 0;
  bool chk = true;
  while (idx < n) {
    long long p = A[idx];
    long long cnt = 0;
    while (idx < n && p == A[idx]) {
      idx++;
      cnt++;
    }
    div = (div * (cnt + 1LL)) % (2LL * (1000000007 - 1));
    chk = (chk && (cnt % 2 == 0));
  }
  div = (div % ((1000000007 - 1) * 2LL)) / 2;
  long long ans = fast_pow(num, div);
  if (chk) {
    idx = 0;
    while (idx < n) {
      long long p = A[idx];
      long long cnt = 0;
      while (idx < n && p == A[idx]) {
        idx++;
        cnt++;
      }
      ans = (ans * fast_pow(p, cnt / 2)) % 1000000007;
    }
  }
  cout << ans << endl;
  return 0;
}
