#include <bits/stdc++.h>
using namespace std;
int pos[300000];
long long cnt[300000], a[300000];
const long long p = 1000000007;
long long power(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % p;
    b >>= 1;
    a = (a * a) % p;
  }
  return ans;
}
int main() {
  int m;
  cin >> m;
  int n = 0;
  for (int i = 1; i <= m; ++i) {
    int x;
    cin >> x;
    if (!pos[x]) {
      pos[x] = ++n;
      cnt[n] = 1;
      a[n] = x;
    } else
      cnt[pos[x]]++;
  }
  int f = 1;
  long long sum = 1;
  for (int i = 1; i <= n; ++i) {
    if (cnt[i] % 2 && f) {
      f = 0;
      sum = (sum * ((cnt[i] + 1) / 2)) % (p - 1);
    } else
      sum = (sum * (cnt[i] + 1)) % (p - 1);
  }
  long long ans = 1;
  for (int i = 1; i <= n; ++i) {
    if (f)
      ans = (ans * power(a[i], ((cnt[i] / 2) * sum) % (p - 1))) % p;
    else
      ans = (ans * power(a[i], (cnt[i] * sum) % (p - 1))) % p;
  }
  cout << ans << endl;
  return 0;
}
