#include <bits/stdc++.h>
using namespace std;
long long power(long long base, long long exponent) {
  if (exponent == 0) return 1;
  long long s = power(base, exponent / 2), t;
  s %= 1000000007;
  t = s * s;
  t %= 1000000007;
  if (exponent % 2 == 0) return t;
  t *= base;
  t %= 1000000007;
  return t;
}
int main() {
  long long m, k;
  bool a = 1;
  vector<int> amounts;
  amounts.resize(200000, 1);
  cin >> m;
  long long mult = 1, result = 1, resultroot = 1;
  for (int i = 0; i < m; ++i) {
    cin >> k;
    amounts[k]++;
    result *= k;
    result %= 1000000007;
    if (amounts[k] % 2 == 0) {
      resultroot *= k;
      resultroot %= 1000000007;
    }
  }
  for (int i = 0; i < 200000; ++i) {
    if (a && (amounts[i] % 2 == 0)) {
      mult *= (amounts[i] / 2);
      a = 0;
    } else
      mult *= amounts[i];
    mult %= 1000000006;
  }
  if (a == 0) {
    cout << power(result, mult);
  } else {
    cout << power(resultroot, mult);
  }
  return 0;
}
