#include <bits/stdc++.h>
using namespace std;
const uint64_t kMod = 1e9 + 7;
const int kM = 2e5 + 1;
int m;
map<uint64_t, int> mp;
uint64_t Pow(uint64_t x, uint64_t y) {
  x %= kMod;
  if (y == 0) return 1;
  return (y & 1 ? x : 1) * Pow(x * x, y >> 1) % kMod;
}
int main(int argc, char** argv) {
  ios_base::sync_with_stdio(false);
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int p;
    cin >> p;
    mp[p]++;
  }
  uint64_t ans = 1, d = 1;
  for (auto pc : mp) {
    uint64_t p = pc.first, c = pc.second;
    uint64_t v = Pow(p, c * (c + 1) / 2);
    ans = (Pow(ans, (c + 1)) * Pow(v, d)) % kMod;
    d = d * (c + 1) % (kMod - 1);
  }
  cout << ans << endl;
  return 0;
}
