#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
  long long int x = (a) % 1000000007, y = 1;
  while (b) {
    if (b % 2 != 0) y = (y * x) % 1000000007;
    x = (x * x) % 1000000007;
    b /= 2;
  }
  return y;
}
long long cnt[200003] = {0}, l[200003] = {0}, r[200003] = {0};
int main() {
  long long int m, i, x, temp, ans = 1, k;
  scanf("%I64d", &m);
  for (i = 0; i < m; i++) {
    scanf("%I64d", &x);
    cnt[x]++;
  }
  l[2] = cnt[2] + 1;
  for (i = 3; i <= 200000; i++) {
    if (cnt[i]) {
      if (l[i - 1] == 0)
        l[i] = (cnt[i] + 1) % (1000000007 - 1);
      else
        l[i] = (l[i - 1] * (cnt[i] + 1)) % (1000000007 - 1);
    } else
      l[i] = l[i - 1];
  }
  r[200000] = cnt[200000];
  for (i = 200000; i >= 2; i--) {
    if (cnt[i]) {
      if (r[i + 1] == 0)
        r[i] = (cnt[i] + 1) % (1000000007 - 1);
      else
        r[i] = (r[i + 1] * (cnt[i] + 1)) % (1000000007 - 1);
    } else
      r[i] = r[i + 1];
  }
  for (i = 2; i <= 200000; i++) {
    if (cnt[i]) {
      temp = 1;
      k = 1;
      if (l[i - 1] == 0 && r[i + 1] == 0)
        temp = 1;
      else if (l[i - 1] == 0)
        temp = r[i + 1];
      else if (r[i + 1] == 0)
        temp = l[i - 1];
      else
        temp = (r[i + 1] * l[i - 1]) % (1000000007 - 1);
      k = ((cnt[i] * (cnt[i] + 1)) / 2) % (1000000007 - 1);
      k = (temp * k) % (1000000007 - 1);
      ans = (ans * power(i, k)) % 1000000007;
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
