Ayrat has number n, represented as it's prime factorization pi of size m, i.e. n = p1·p2·...·pm. Ayrat got secret information that that the product of all divisors of n taken modulo 109 + 7 is the password to the secret data base. Now he wants to calculate this value.

Input

The first line of the input contains a single integer m (1 ≤ m ≤ 200 000) — the number of primes in factorization of n. 

The second line contains m primes numbers pi (2 ≤ pi ≤ 200 000).

Output

Print one integer — the product of all divisors of n modulo 109 + 7.

Examples

Input

2
2 3


Output

36


Input

3
2 3 2


Output

1728

Note

In the first sample n = 2·3 = 6. The divisors of 6 are 1, 2, 3 and 6, their product is equal to 1·2·3·6 = 36.

In the second sample 2·3·2 = 12. The divisors of 12 are 1, 2, 3, 4, 6 and 12. 1·2·3·4·6·12 = 1728.
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int up = 1e6;
long long bin_pow(long long a, long long n) {
  if (n == 0) return 1;
  if (n == 1) return a % mod;
  long long q = bin_pow(a, n / 2);
  q = q * q % mod;
  if (n & 1) q = q * a % mod;
  return q;
}
long long inv(long long a) { return bin_pow(a, mod - 2); }
void print(vector<long long> a) {
  for (int x : a) {
    cout << x << " ";
  }
  cout << "\n";
}
long long sum(long long a) { return a * (a + 1) / 2; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  int n;
  cin >> n;
  vector<int> p(up);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    p[x]++;
  }
  vector<long long> cnt;
  for (int i = 2; i < up; i++) {
    if (p[i]) cnt.push_back(p[i]);
  }
  int N = cnt.size();
  vector<long long> pref(N);
  vector<long long> suf(N);
  pref[0] = cnt[0] + 1;
  suf[N - 1] = cnt.back() + 1;
  for (int i = 1; i < N; i++) {
    pref[i] = pref[i - 1] * (cnt[i] + 1) % (mod - 1);
  }
  for (int i = N - 2; i >= 0; i--) {
    suf[i] = suf[i + 1] * (cnt[i] + 1) % (mod - 1);
  }
  long long res = 1;
  vector<long long> exp;
  for (int i = 0; i < N; i++) {
    long long left = (i > 0) ? pref[i - 1] : 1;
    long long right = (i < N - 1) ? suf[i + 1] : 1;
    long long mul = left * right % (mod - 1);
    long long tmp = sum(cnt[i]) % (mod - 1);
    tmp = tmp * mul % (mod - 1);
    exp.push_back(tmp);
  }
  int pt = 0;
  for (int i = 0; i < up; i++) {
    if (p[i]) {
      long long tmp = bin_pow(i, exp[pt++]);
      res = res * tmp % mod;
    }
  }
  cout << res << "\n";
  return 0;
}
