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 = 1000000007;
vector<int> p;
int a[200000];
long long pot(long long x, long long e) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    long long b = (x * x) % MOD;
    return pot(b, e / 2) % MOD;
  } else {
    long long b = (x * x) % MOD;
    return (x * (pot(b, e / 2) % MOD)) % MOD;
  }
}
int main() {
  ios::sync_with_stdio(false);
  int X = 1;
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (!a[x]) {
      p.push_back(x);
      a[x] = 1;
    } else
      a[x]++;
  }
  for (int i = 0; i < p.size(); i++)
    if (a[p[i]] % 2 != 0) X = 0;
  long long ans = 1;
  if (!X) {
    for (int i = 0; i < p.size(); i++) {
      long long b = pot(p[i], a[p[i]]) % MOD;
      ans = ((ans % MOD) * (b % MOD)) % MOD;
    }
    int done = 0;
    for (int i = 0; i < p.size(); i++) {
      int alpha = (a[p[i]] + 1);
      if (!done && a[p[i]] % 2 != 0) {
        done = 1;
        alpha /= 2;
      }
      ans = pot(ans, alpha) % MOD;
    }
  } else {
    for (int i = 0; i < p.size(); i++) {
      long long b = pot(p[i], a[p[i]] / 2) % MOD;
      ans = ((ans % MOD) * (b % MOD)) % MOD;
    }
    for (int i = 0; i < p.size(); i++) {
      int alpha = (a[p[i]] + 1);
      ans = pot(ans, alpha) % MOD;
    }
  }
  cout << ans << endl;
  return 0;
}
