#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
const long long int mod = 1e9 + 6;
const long double PI = acos(-1);
const long double EPS = 1e-9;
const long long int INF = 1e18;
const auto start_time = std::chrono::high_resolution_clock::now();
void TIME() {}
long long int power2(long long int a, long long int b) {
  if (b == 0) {
    return 1;
  }
  long long int mul = power2(a, b / 2);
  if (b % 2) {
    return ((mul * a) % MOD * mul) % MOD;
  }
  return (mul * mul) % MOD;
}
long long int power(long long int x, long long int y) {
  long long int p = MOD;
  long long int res = 1;
  x = x % p;
  if (x == 0) {
    return 0;
  }
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
void solve() {
  long long int m;
  cin >> m;
  vector<long long int> v(m);
  for (auto &invec : v) cin >> invec;
  map<long long int, long long int> make_pair;
  for (long long int i = 0; i < m; i++) {
    make_pair[v[i]]++;
  }
  vector<long long int> mul(200005, 1);
  long long int mult = 1;
  for (auto i : make_pair) {
    mul[i.first] = mult;
    mult *= (i.second + 1);
    mult %= mod;
  }
  long long int res = 1;
  for (auto i : make_pair) {
    long long int x = i.first;
    long long int y = i.second;
    y = (y * (y + 1) / 2) % mod;
    long long int px = power(x, y);
    res = power(res, i.second + 1) % MOD;
    res *= power(px, mul[i.first]);
    res %= MOD;
  }
  cout << res << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  TIME();
  return 0;
}
