#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long pow_a = a % 1000000007, res = 1;
  while (b > 0) {
    if (b & 1) res = (res * pow_a) % 1000000007;
    b /= 2;
    pow_a = (pow_a * pow_a) % 1000000007;
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  map<long long, int> m;
  for (__typeof(n) i = (0); i != (n); i++) {
    long long t;
    cin >> t;
    if (m.find(t) == m.end()) m[t] = 0;
    m[t]++;
  }
  long long pro = 1, count = 1;
  for (__typeof(m.end()) i = (m.begin()); i != (m.end()); i++) {
    int a = i->second;
    pro = power(pro, a + 1);
    long long temp = a;
    temp = (temp * (a + 1)) / 2;
    temp = temp % (1000000007 - 1);
    temp = (count * temp) % (1000000007 - 1);
    count = (count * (a + 1)) % (1000000007 - 1);
    pro = (pro * power(i->first, temp)) % 1000000007;
  }
  cout << pro << endl;
  return 0;
}
