#include <bits/stdc++.h>
using namespace std;
const long long int ZERO = 0LL;
const long long int ONE = 1LL;
const int N = 2e5 + 1;
const int K = 20;
const long long int OO = 1e18;
const double PI = acos(-1);
const long long int MD = 1e9 + 7;
long long int add(long long int a, long long int b) {
  return (a * 1LL + b) % MD;
}
long long int mult(long long int a, long long int b) {
  return (a * 1LL * b) % MD;
}
long long int fp(long long int x, long long int y, long long int p) {
  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;
}
int t = 1;
int n;
int fr[200001];
vector<int> v;
int main() {
  while (t--) {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
      int item;
      scanf("%d", &item);
      fr[item]++;
    }
    vector<vector<int> > v;
    for (int i = 0; i < 200001; i++) {
      int have = 1;
      vector<int> av;
      while (fr[i]--) {
        have = mult(have, i);
        av.push_back(have);
      }
      if (av.size()) v.push_back(av);
    }
    n = v.size() - 1;
    int ans = 1;
    int count = 0;
    for (int i = n; i >= 0; i--) {
      int acount = count;
      int ians = 1;
      for (int j = 0; j < v[i].size(); j++) {
        acount = ((acount % (MD - 1)) + ((count + 1) % (MD - 1))) % (MD - 1);
        ians = mult(ians, mult(ans, fp(v[i][j], (count + 1) % (MD - 1), MD)));
      }
      ans = mult(ans, ians);
      count = acount;
    }
    printf("%d", ans);
  }
  return 0;
}
