#include <bits/stdc++.h>
using namespace std;
int freq[1000000] = {0};
long long BigMod(long long a, long long b, long long mod) {
  if (!b) return 1;
  long long x = BigMod(a, b / 2, mod);
  x = (x * x) % mod;
  if (b & 1)
    return (x * a) % mod;
  else
    return x;
}
long long calc(long long a, long long b) {
  b %= (1000000007 - 1);
  return BigMod(a, b, 1000000007);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    freq[a] += 1;
  }
  int all2 = 1;
  for (int i = 1; i < 300000; i++) {
    if (freq[i] % 2) all2 = 0;
  }
  if (all2) {
    long long fac = 1;
    long long base = 1;
    for (int i = 1; i < 300000; i++) {
      fac *= (freq[i] + 1);
      fac %= (1000000007 - 1);
      freq[i] /= 2;
      base = (base * calc(i, freq[i])) % 1000000007;
    }
    cout << calc(base, fac) << endl;
  } else {
    long long fac = 1;
    long long base = 1;
    for (int i = 1; i < 300000; i++) {
      if (freq[i] % 2 && !all2) {
        fac *= (freq[i] + 1) / 2;
        all2 = 1;
      } else
        fac *= (freq[i] + 1);
      fac %= (1000000007 - 1);
      base = (base * calc(i, freq[i])) % 1000000007;
    }
    cout << calc(base, fac) << endl;
  }
  return 0;
}
