#include <bits/stdc++.h>
using namespace std;
const int MAX_N = (int)2e5 + 100;
const int mod = (int)1e9 + 7;
int cnt[MAX_N];
inline int mul(int x, int y) { return (long long)x * y % mod; }
inline int powMod(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret = mul(ret, x);
    x = mul(x, x);
    n >>= 1;
  }
  return ret;
}
int main() {
  int m;
  scanf("%d", &m);
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < m; ++i) {
    int p;
    scanf("%d", &p);
    ++cnt[p];
  }
  vector<int> toMul;
  for (int i = 0; i < MAX_N; ++i)
    if (cnt[i] > 0) {
      toMul.push_back(cnt[i] + 1);
    }
  bool perfectSq = true;
  for (int i = 0; i < toMul.size(); ++i) {
    if (toMul[i] % 2 == 0) {
      toMul[i] /= 2;
      perfectSq = false;
      break;
    }
  }
  int p1 = 1;
  for (int i = 0; i < toMul.size(); ++i) {
    p1 = (long long)p1 * toMul[i] % (mod - 1);
  }
  if (!perfectSq) {
    int num = 1;
    for (int i = 0; i < MAX_N; ++i)
      if (cnt[i] > 0) {
        num = mul(num, powMod(i, cnt[i]));
      }
    printf("%d\n", powMod(num, p1));
  } else {
    int root = 1;
    for (int i = 0; i < MAX_N; ++i)
      if (cnt[i] > 0) {
        root = mul(root, powMod(i, cnt[i] / 2));
      }
    printf("%d\n", powMod(root, p1));
  }
  return 0;
}
