#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7, N = 2e5;
int mul(int a, int b) { return (a * 1LL * b) % mod; }
int mul2(int a, int b) { return (a * 1LL * b) % (mod - 1); }
int Pow(int v, long long p) {
  int ans = 1;
  while (p) {
    if (p & 1) {
      ans = mul(ans, v);
    }
    p /= 2;
    v = mul(v, v);
  }
  return ans;
}
long long F(int n) { return n * 1LL * (n + 1) / 2; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  map<int, int> p;
  while (n--) {
    int x;
    cin >> x;
    ++p[x];
  }
  int mult = 1, sum = 1, last = 1;
  for (auto e : p) {
    last = Pow(last, e.second + 1);
    mult = Pow(Pow(e.first, F(e.second)), sum);
    sum = mul2(sum, e.second + 1);
    last = mul(mult, last);
  }
  cout << last;
  return 0;
}
