#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const long long mod = 1e9 + 7;
int w[N];
long long vis[N];
inline long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % mod;
    b >>= 1;
    a = a * a % mod;
  }
  return res;
}
int main() {
  int n, m = 0, v, flag = 0;
  long long c = 1, ans = 1;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &v);
    if (vis[v] == 0) w[++m] = v;
    vis[v]++;
  }
  for (int i = 1; i <= m; i++) flag |= (vis[w[i]] & 1);
  if (flag) {
    int tag = 1;
    for (int i = 1; i <= m; i++) {
      if ((vis[w[i]] & 1) && tag)
        c = c * ((vis[w[i]] + 1) / 2) % (mod - 1), tag = 0;
      else
        c = c * (vis[w[i]] + 1) % (mod - 1);
    }
    for (int i = 1; i <= m; i++)
      ans = ans * power(w[i], vis[w[i]] * c % (mod - 1)) % mod;
    printf("%lld\n", ans);
  } else {
    for (int i = 1; i <= m; i++) c = c * ((vis[w[i]] + 1)) % (mod - 1);
    for (int i = 1; i <= m; i++)
      ans = ans * power(w[i], c * (vis[w[i]] / 2) % (mod - 1)) % mod;
    printf("%lld\n", ans);
  }
  return 0;
}
