#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
const long long MOD = 1e9 + 7;
inline long long sum(long long a, long long b) { return (a + b) % MOD; }
inline long long mult(long long a, long long b) { return (a * b) % MOD; }
long long bin_pow(long long a, long long n) {
  if (n == 0) return 1;
  if (n & 1)
    return mult(a, bin_pow(a, n - 1));
  else {
    long long temp = bin_pow(a, n / 2);
    return mult(temp, temp);
  }
}
int cnt[N];
int main() {
  for (int i = 0; i < N; ++i) cnt[i] = 0;
  int m;
  scanf("%d", &m);
  for (int i = 0, p; i < m; ++i) {
    scanf("%d", &p);
    ++cnt[p];
  }
  bool f = false;
  for (int i = 1; i < N; ++i) {
    if (cnt[i] > 0) f |= (cnt[i] & 1);
  }
  long long n = 1;
  if (f) {
    for (int i = 1; i < N; ++i) {
      n = mult(n, bin_pow(i, cnt[i]));
    }
    for (int i = 1; i < N; ++i) {
      if (cnt[i] == 0) continue;
      if ((cnt[i] & 1) && f) {
        f = false;
        n = bin_pow(n, (cnt[i] + 1) / 2);
      } else
        n = bin_pow(n, cnt[i] + 1);
    }
  } else {
    for (int i = 1; i < N; ++i) {
      n = mult(n, bin_pow(i, cnt[i] / 2));
    }
    for (int i = 1; i < N; ++i) {
      if (cnt[i] == 0) continue;
      n = bin_pow(n, cnt[i] + 1);
    }
  }
  printf("%I64d", n);
}
