#include<bits/stdc++.h>
using namespace std;

#define ll       long long
#define ull      unsigned long long
#define ld       long double
#define pii      pair<int,int>
#define pll      pair<ll,ll>
#define vi       vector<int>
#define vll      vector<ll>
#define vc       vector<char>
#define vs       vector<string>
#define vpii     vector< pair<int,int> >
#define vpll     vector< pair<ll,ll> >
#define pip      pair< int,pii >
#define ppi      pair< pii,int >
#define sei      set<int>
#define usei     unordered_set<int>
#define ses      set<string>
#define sepii    set< pair<int,int> >
#define di       deque<int>
#define li       list<int>
#define sti      stack<int>
#define qi       queue<int>
#define pqi      priority_queue<int>
#define mpii      map<int,int>
#define mpll      map<ll,ll>
#define umii     unordered_map<int,int>
#define vit      vector<int>::iterator
#define mit      map<int,int>::iterator
#define sit      set<int>:: iterator
#define umap     unordered_map
#define uset     unordered_set
#define PQ       priority_queue

#define rep(i,n)        for(i=0;i<n;i++)
#define itfor(i, c)     for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define printa(a,L,R)   for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a)       printa(a,0,a.size())
#define print2d(a,r,c)  for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
#define pb              push_back
#define MP              make_pair
#define SQ(x)           ((x)*(x))
#define F               first
#define S               second
#define mem(a,x)        memset(a,x,sizeof(a))
#define inf             0x3f3f3f3f
#define PI              3.14159265358979323846
#define E               2.71828182845904523536
#define gamma           0.5772156649
#define nl              "\n"
#define lg(r,n)         (int)(log2(n)/log2(r))
#define sf(a)           scanf("%d",&a)
#define sfl(a)          scanf("%lld",&a)
#define sfc(a)          scanf("%c",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sffl(a,b)       scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define pf              printf
#define pfi(a)          pf("%d\n",&a)
#define pfl(a)          pf("%lld\n",&a)
#define _ccase          printf("Case %d: ",++cs)
#define _case           cout<<"Case "<<++cs<<": "
#define debug(x)        cout<<#x"="<<(x)<<nl

#define rev(v)              reverse(v.begin(),v.end())
#define srt(v)              sort(v.begin(),v.end())
#define grtsrt(v)           sort(v.begin(),v.end(),greater<int>())
#define all(v)              v.begin(),v.end()
#define mnv(v)              *min_element(v.begin(),v.end())
#define mxv(v)              *max_element(v.begin(),v.end())
#define countv(v,a)         count(v.begin(),v.end(),a)
#define toint(a)            atoi(a.c_str())
#define fast                ios_base::sync_with_stdio(false),cin.tie(NULL)
string  tostr(int n)        {stringstream rr;rr<<n;return rr.str();}
const int mod=1e9+7;
ll qpow(ll n,ll k)          {ll ans=1;n%=mod;while(k){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans;}
const int mxn=2e5+9;
const ld eps=1e-9;

ull i,j,k,n,ans=1LL,freq[mxn+5],tmp,tmp2,lmul[mxn+5],rmul[mxn+5];
int main()
{
    fast;
    cin>>n;
    rep(i,n) cin>>k,freq[k]++;
    lmul[0]=1;
    for(i=1;i<mxn;i++) lmul[i]=(lmul[i-1]*(freq[i]+1))%mod;
    rmul[mxn-1]=1;
    for(i=mxn-2;i>0;i--) rmul[i]=(rmul[i+1]*(freq[i]+1))%mod;
    for(i=1;i<mxn;i++){
        if(freq[i]){
            k=(freq[i]*(freq[i]+1)/2)%mod;
            tmp=(lmul[i-1]*rmul[i+1])%mod;
            tmp2=qpow(i,(k*tmp)%mod)%mod;
            ans=(ans*tmp2)%mod;
        }
    }
    cout<<ans<<nl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll       long long
#define ull      unsigned long long
#define ld       long double
#define pii      pair<int,int>
#define pll      pair<ll,ll>
#define vi       vector<int>
#define vll      vector<ll>
#define vc       vector<char>
#define vs       vector<string>
#define vpii     vector< pair<int,int> >
#define vpll     vector< pair<ll,ll> >
#define pip      pair< int,pii >
#define ppi      pair< pii,int >
#define sei      set<int>
#define usei     unordered_set<int>
#define ses      set<string>
#define sepii    set< pair<int,int> >
#define di       deque<int>
#define li       list<int>
#define sti      stack<int>
#define qi       queue<int>
#define pqi      priority_queue<int>
#define mpii      map<int,int>
#define mpll      map<ll,ll>
#define umii     unordered_map<int,int>
#define vit      vector<int>::iterator
#define mit      map<int,int>::iterator
#define sit      set<int>:: iterator
#define umap     unordered_map
#define uset     unordered_set
#define PQ       priority_queue

#define rep(i,n)        for(i=0;i<n;i++)
#define itfor(i, c)     for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define printa(a,L,R)   for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a)       printa(a,0,a.size())
#define print2d(a,r,c)  for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
#define pb              push_back
#define MP              make_pair
#define SQ(x)           ((x)*(x))
#define F               first
#define S               second
#define mem(a,x)        memset(a,x,sizeof(a))
#define inf             0x3f3f3f3f
#define PI              3.14159265358979323846
#define E               2.71828182845904523536
#define gamma           0.5772156649
#define nl              "\n"
#define lg(r,n)         (int)(log2(n)/log2(r))
#define sf(a)           scanf("%d",&a)
#define sfl(a)          scanf("%lld",&a)
#define sfc(a)          scanf("%c",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sffl(a,b)       scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define pf              printf
#define pfi(a)          pf("%d\n",&a)
#define pfl(a)          pf("%lld\n",&a)
#define _ccase          printf("Case %d: ",++cs)
#define _case           cout<<"Case "<<++cs<<": "
#define debug(x)        cout<<#x"="<<(x)<<nl

#define rev(v)              reverse(v.begin(),v.end())
#define srt(v)              sort(v.begin(),v.end())
#define grtsrt(v)           sort(v.begin(),v.end(),greater<int>())
#define all(v)              v.begin(),v.end()
#define mnv(v)              *min_element(v.begin(),v.end())
#define mxv(v)              *max_element(v.begin(),v.end())
#define countv(v,a)         count(v.begin(),v.end(),a)
#define toint(a)            atoi(a.c_str())
#define fast                ios_base::sync_with_stdio(false),cin.tie(NULL)
string  tostr(int n)        {stringstream rr;rr<<n;return rr.str();}
const int mod=1e9+7;
ll qpow(ll n,ll k)          {ll ans=1;n%=mod;while(k){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans;}
const int mxn=2e5+9;
const ld eps=1e-9;

ll i,j,k,n,ans=1,freq[mxn+5],tmp,tmp2,lmul[mxn+5],rmul[mxn+5];
int main()
{
    fast;
    cin>>n;
    rep(i,n) cin>>k,freq[k]++;
    lmul[0]=1;
    for(i=1;i<mxn;i++) lmul[i]=(lmul[i-1]*(freq[i]+1))%mod;
    rmul[mxn-1]=1;
    for(i=mxn-2;i>=0;i--) rmul[i]=(rmul[i+1]*(freq[i]+1))%mod;
    for(i=1;i<mxn;i++){
        if(freq[i]){
            k=(freq[i]*(freq[i]+1)/2)%mod;
            tmp=(lmul[i-1]*rmul[i+1])%mod;
            tmp2=qpow(i,(k*tmp)%mod)%mod;
            ans=(ans*tmp2)%mod;
        }
    }
    cout<<ans<<nl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll       long long
#define ull      unsigned long long
#define ld       long double
#define pii      pair<int,int>
#define pll      pair<ll,ll>
#define vi       vector<int>
#define vll      vector<ll>
#define vc       vector<char>
#define vs       vector<string>
#define vpii     vector< pair<int,int> >
#define vpll     vector< pair<ll,ll> >
#define pip      pair< int,pii >
#define ppi      pair< pii,int >
#define sei      set<int>
#define usei     unordered_set<int>
#define ses      set<string>
#define sepii    set< pair<int,int> >
#define di       deque<int>
#define li       list<int>
#define sti      stack<int>
#define qi       queue<int>
#define pqi      priority_queue<int>
#define mpii      map<int,int>
#define mpll      map<ll,ll>
#define umii     unordered_map<int,int>
#define vit      vector<int>::iterator
#define mit      map<int,int>::iterator
#define sit      set<int>:: iterator
#define umap     unordered_map
#define uset     unordered_set
#define PQ       priority_queue

#define rep(i,n)        for(i=0;i<n;i++)
#define itfor(i, c)     for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define printa(a,L,R)   for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a)       printa(a,0,a.size())
#define print2d(a,r,c)  for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
#define pb              push_back
#define MP              make_pair
#define SQ(x)           ((x)*(x))
#define F               first
#define S               second
#define mem(a,x)        memset(a,x,sizeof(a))
#define inf             0x3f3f3f3f
#define PI              3.14159265358979323846
#define E               2.71828182845904523536
#define gamma           0.5772156649
#define nl              "\n"
#define lg(r,n)         (int)(log2(n)/log2(r))
#define sf(a)           scanf("%d",&a)
#define sfl(a)          scanf("%lld",&a)
#define sfc(a)          scanf("%c",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sffl(a,b)       scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define pf              printf
#define pfi(a)          pf("%d\n",&a)
#define pfl(a)          pf("%lld\n",&a)
#define _ccase          printf("Case %d: ",++cs)
#define _case           cout<<"Case "<<++cs<<": "
#define debug(x)        cout<<#x"="<<(x)<<nl

#define rev(v)              reverse(v.begin(),v.end())
#define srt(v)              sort(v.begin(),v.end())
#define grtsrt(v)           sort(v.begin(),v.end(),greater<int>())
#define all(v)              v.begin(),v.end()
#define mnv(v)              *min_element(v.begin(),v.end())
#define mxv(v)              *max_element(v.begin(),v.end())
#define countv(v,a)         count(v.begin(),v.end(),a)
#define toint(a)            atoi(a.c_str())
#define fast                ios_base::sync_with_stdio(false),cin.tie(NULL)
string  tostr(int n)        {stringstream rr;rr<<n;return rr.str();}
const int mod=1e9+7;
ll qpow(ll n,ll k)          {ll ans=1;n%=mod;while(k){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans;}
const int mxn=2e5+9;
const ld eps=1e-9;

ll i,j,k,n,ans=1LL,freq[mxn+5],tmp,tmp2,lmul[mxn+5],rmul[mxn+5];
int main()
{
    fast;
    cin>>n;
    rep(i,n) cin>>k,freq[k]++;
    lmul[0]=1;
    for(i=1;i<mxn;i++) lmul[i]=(lmul[i-1]*(freq[i]+1))%(mod-1);
    rmul[mxn-1]=1;
    for(i=mxn-2;i>=0;i--) rmul[i]=(rmul[i+1]*(freq[i]+1))%(mod-1);
    for(i=1;i<mxn;i++){
        if(freq[i]){
            k=(freq[i]*(freq[i]+1)/2)%(mod-1);
            tmp=(lmul[i-1]*rmul[i+1])%(mod-1);
            tmp2=qpow(i,(k*tmp)%(mod-1))%(mod-1);
            ans=(ans*tmp2)%mod;
        }
    }
    cout<<ans<<nl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll       long long
#define ull      unsigned long long
#define ld       long double
#define pii      pair<int,int>
#define pll      pair<ll,ll>
#define vi       vector<int>
#define vll      vector<ll>
#define vc       vector<char>
#define vs       vector<string>
#define vpii     vector< pair<int,int> >
#define vpll     vector< pair<ll,ll> >
#define pip      pair< int,pii >
#define ppi      pair< pii,int >
#define sei      set<int>
#define usei     unordered_set<int>
#define ses      set<string>
#define sepii    set< pair<int,int> >
#define di       deque<int>
#define li       list<int>
#define sti      stack<int>
#define qi       queue<int>
#define pqi      priority_queue<int>
#define mpii      map<int,int>
#define mpll      map<ll,ll>
#define umii     unordered_map<int,int>
#define vit      vector<int>::iterator
#define mit      map<int,int>::iterator
#define sit      set<int>:: iterator
#define umap     unordered_map
#define uset     unordered_set
#define PQ       priority_queue

#define rep(i,n)        for(i=0;i<n;i++)
#define itfor(i, c)     for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define printa(a,L,R)   for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a)       printa(a,0,a.size())
#define print2d(a,r,c)  for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
#define pb              push_back
#define MP              make_pair
#define SQ(x)           ((x)*(x))
#define F               first
#define S               second
#define mem(a,x)        memset(a,x,sizeof(a))
#define inf             0x3f3f3f3f
#define PI              3.14159265358979323846
#define E               2.71828182845904523536
#define gamma           0.5772156649
#define nl              "\n"
#define lg(r,n)         (int)(log2(n)/log2(r))
#define sf(a)           scanf("%d",&a)
#define sfl(a)          scanf("%lld",&a)
#define sfc(a)          scanf("%c",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sffl(a,b)       scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define pf              printf
#define pfi(a)          pf("%d\n",&a)
#define pfl(a)          pf("%lld\n",&a)
#define _ccase          printf("Case %d: ",++cs)
#define _case           cout<<"Case "<<++cs<<": "
#define debug(x)        cout<<#x"="<<(x)<<nl

#define rev(v)              reverse(v.begin(),v.end())
#define srt(v)              sort(v.begin(),v.end())
#define grtsrt(v)           sort(v.begin(),v.end(),greater<int>())
#define all(v)              v.begin(),v.end()
#define mnv(v)              *min_element(v.begin(),v.end())
#define mxv(v)              *max_element(v.begin(),v.end())
#define countv(v,a)         count(v.begin(),v.end(),a)
#define toint(a)            atoi(a.c_str())
#define fast                ios_base::sync_with_stdio(false),cin.tie(NULL)
string  tostr(int n)        {stringstream rr;rr<<n;return rr.str();}
const int mod=1e9+7;
ll qpow(ll n,ll k)          {ll ans=1;while(k){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans;}
const int mxn=2e5+9;
const ld eps=1e-9;

ll i,j,k,n,ans=1,freq[mxn],tmp,tmp2,lmul[mxn],rmul[mxn];
int main()
{
    fast;
    cin>>n;
    rep(i,n) cin>>k,freq[k]++;
    lmul[0]=1;
    for(i=1;i<mxn;i++) lmul[i]=(lmul[i-1]*(freq[i]+1))%mod;
    rmul[mxn-1]=1;
    for(i=mxn-2;i>=0;i--) rmul[i]=(rmul[i+1]*(freq[i]+1))%mod;
    for(i=1;i<mxn;i++){
        if(freq[i]){
            k=(freq[i]*(freq[i]+1)/2)%mod;
            tmp=(lmul[i-1]*rmul[i+1])%mod;
            tmp2=qpow(i,(k*tmp)%mod);
            ans=(ans*tmp2)%mod;
        }
    }
    cout<<ans<<nl;
    return 0;
}


#include<algorithm>
#include<math.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<stdlib.h>
#include<string>
#define forto(i,x,y) for(long long i=(x),_b=(y);i<=_b;++i)
#define forco(i,x,y) for(long long i=(x),_b=(y);i>=_b;--i)
#define ii pair<long long,long long>
using namespace std;
const long long oo = 1e7 + 5;
const long long lim = 999999;
const long long mod = 1e9 + 7;

long long n, p, times;
long long a, b;
long long fir, snd;
long long ans, d;

map<long long, long long> cnt;

long long pw(long long a, long long b)
{
	if (b == 0) return (1 + mod*mod) % mod;
	if (b == 1) return (a + mod*mod) % mod;
	long long res = pow(a, b / 2);
	res = (res*res + mod*mod) % mod;

	if (b & 1) return (res*a + mod*mod) % mod; else return (res + mod*mod) % mod;
}

signed main()
{
	/*Coding or to be coded*/

	cin >> n;
	forto(i, 1, n)
	{
		cin >> p; cnt[p]++;
	}

	ans = d = 1;
	for (auto v : cnt)
	{
		a = v.first;
		b = v.second;

		times = (b*(b + 1) / 2);

		fir = pw(a, times);
		ans = (pw(fir, d)*pw(ans, b + 1)) % mod;

		d = d*(b + 1) % (mod - 1);
	}

	cout << ans % mod;

	/*When you want to give up,which cause make you start*/

	/*If you stop,you still go alone*/
}


#include<algorithm>
#include<math.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<stdlib.h>
#include<string>
#define forto(i,x,y) for(long long i=(x),_b=(y);i<=_b;++i)
#define forco(i,x,y) for(long long i=(x),_b=(y);i>=_b;--i)
#define ii pair<long long,long long>
using namespace std;
const long long oo = 1e7 + 5;
const long long lim = 999999;
const long long mod = 1e9 + 7;

long long n, p, times;
long long a, b;
long long fir, snd;

map<long long, long long> cnt;

long long pw(long long a, long long q) {
	a %= mod;
	if (q == 0) return 1;
	return ((q % 2 == 1 ? a : 1) * pw(a * a, q / 2)) % mod;
}

signed main()
{
	/*Coding or to be coded*/

	cin >> n;
	forto(i, 1, n)
	{
		cin >> p; cnt[p]++;
	}

	long long d = 1;
	long long ans = 1;
	for (auto x : cnt) {
		long long cnt = x.second;
		long long p = x.first;
		long long fp = pw(p, (cnt + 1) * cnt / 2);
		ans = pw(ans, (cnt + 1)) * pw(fp, d) % mod;
		d = d * (x.second + 1) % (mod - 1);
	}
	cout << ans << endl;

	/*When you want to give up,which cause make you start*/

	/*If you stop,you stilong long go alone*/
}


#include<algorithm>
#include<math.h>
#include<iostream>
#include<stdio.h>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<stdlib.h>
#include<iomanip>
#include<time.h>
#define forto(i,x,y) for(long long i=(x),_b=(y);i<=_b;++i)
#define forco(i,x,y) for(long long i=(x),_b=(y);i>=_b;--i)
#define ii pair<long long,long long>
using namespace std;
const long long oo = 2e5 + 3;
const long long lim = 200001;
const long long mod = 1e9 + 7;

long long tmp1, tmp2;
long long ans;
long long n, p;

long long l[oo], r[oo];

map<long long, long long> cnt;

long long pow(long long x, long long n)
{
	if (n == 0) return 1;
	if (n == 1) return (x) % mod;
	long long res = pow(x, n / 2);
	res = (res*res) % mod;

	if (n & 1) return (res*x) % mod; else return (res) % mod;
}

signed main()
{
	/*Coding or to be coded*/

	ios_base::sync_with_stdio(false);

	cin >> n;
	forto(i, 1, n)
	{
		cin >> p; cnt[p]++;
	}

	l[0] = r[lim + 1] = 1;
	forto(i, 1, lim) l[i] = (l[i - 1] * (cnt[i] + 1)) % (mod-1);
	forco(i, lim, 1) r[i] = (r[i + 1] * (cnt[i] + 1)) % (mod-1);

	ans = 1;
	forto(i, 2, lim)
	{
		if (cnt[i])
		{
			tmp1 = (l[i-1] * r[i+1]) % (mod - 1);
			tmp2 = pow(i, (((cnt[i] * (cnt[i] + 1) / 2) % (mod - 1))*tmp1) % (mod - 1)) % (mod - 1);

			ans = (ans*tmp2) % mod;
		}
	}

	cout << ans;
	/*When you want to give up ,which cause make you start*/

	/*If you stop,you still go alone*/
}


#include<algorithm>
#include<math.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<stdlib.h>
#include<string>
#define forto(i,x,y) for(long long i=(x),_b=(y);i<=_b;++i)
#define forco(i,x,y) for(long long i=(x),_b=(y);i>=_b;--i)
#define ii pair<long long,long long>
using namespace std;
const long long oo = 1e7 + 5;
const long long lim = 999999;
const long long mod = 1e9 + 7;

long long n, p, times;
long long a, b;
long long fir, snd;
long long ans, d;

map<long long, long long> cnt;

long long pw(long long a, long long b)
{
	if (b == 0) return (1 + mod*mod) % mod;
	if (b == 1) return (a + mod*mod) % mod;
	long long res = pow(a, b / 2);
	res = (res*res + mod*mod) % mod;

	if (b & 1) return (res*a + mod*mod) % mod; else return (res + mod*mod) % mod;
}

signed main()
{
	/*Coding or to be coded*/

	cin >> n;
	forto(i, 1, n)
	{
		cin >> p; cnt[p]++;
	}

	ans = d = 1;
	for (auto v : cnt)
	{
		a = v.first;
		b = v.second;

		times = (b*(b + 1) / 2);

		fir = pw(a, times);
		snd = (pw(fir, d)*pw(ans, b + 1)) % mod; ans = (ans*snd) % mod;

		d = d*(b + 1) % (mod - 1);
	}

	cout << ans % mod;

	/*When you want to give up,which cause make you start*/

	/*If you stop,you still go alone*/
}


#include<algorithm>
#include<math.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<stdlib.h>
#include<string>
#define forto(i,x,y) for(long long i=(x),_b=(y);i<=_b;++i)
#define forco(i,x,y) for(long long i=(x),_b=(y);i>=_b;--i)
#define ii pair<long long,long long>
using namespace std;
const long long oo = 1e7 + 5;
const long long lim = 999999;
const long long mod = 1e9 + 7;

long long n, p, times;
long long a, b;
long long fir, snd;
long long ans, d;

map<long long, long long> cnt;

long long pw(long long a, long long b)
{
	if (b == 0) return (1 + mod*mod) % mod;
	if (b == 1) return (a + mod*mod) % mod;
	long long res = pow(a, b / 2);
	res = (res*res + mod*mod) % mod;

	if (b & 1) return (res*a +mod*mod) % mod; else return (res + mod*mod) % mod;
}

signed main()
{
	/*Coding or to be coded*/

	cin >> n;
	forto(i, 1, n)
	{
		cin >> p; cnt[p]++;
	}

	ans = d = 1;
	for (auto v : cnt)
	{
		a = v.first;
		b = v.second;

		times = (b*(b + 1)/2) % mod;

		fir = pw(a, times);
		snd = (pw(fir, d)*pw(ans, b+1)) % mod; ans = (ans*snd) % mod;

		d = d*(b + 1) % (mod - 1);
	}

	cout << ans % mod;

	/*When you want to give up,which cause make you start*/

	/*If you stop,you still go alone*/
}


#include<algorithm>
#include<math.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<stdlib.h>
#include<string>
#define forto(i,x,y) for(long long i=(x),_b=(y);i<=_b;++i)
#define forco(i,x,y) for(long long i=(x),_b=(y);i>=_b;--i)
#define ii pair<long long,long long>
using namespace std;
const long long oo = 1e7 + 5;
const long long lim = 999999;
const long long mod = 1e9 + 7;

long long n, p, times;
long long a, b;
long long fir, snd;
long long ans, d;

map<long long, long long> cnt;

long long pw(long long a, long long b)
{
	if (b == 0) return (1 + mod*mod) % mod;
	if (b == 1) return (a + mod*mod) % mod;
	long long res = pow(a, b / 2);
	res = (res*res + mod*mod) % mod;

	if (b & 1) return (res*a +mod*mod) % mod; else return (res + mod*mod) % mod;
}

signed main()
{
	/*Coding or to be coded*/

	cin >> n;
	forto(i, 1, n)
	{
		cin >> p; cnt[p]++;
	}

	ans = d = 1;
	for (auto v : cnt)
	{
		a = v.first;
		b = v.second;

		times = (b*(b + 1)/2) % mod;

		fir = pw(a, times);
		snd = (pw(fir, d)*pw(ans, times)) % mod; ans = (ans*snd) % mod;

		d = d*(b + 1) % (mod - 1);
	}

	cout << ans % mod;

	/*When you want to give up,which cause make you start*/

	/*If you stop,you still go alone*/
}


#include<algorithm>
#include<math.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<stdlib.h>
#include<string>
#define forto(i,x,y) for(long long i=(x),_b=(y);i<=_b;++i)
#define forco(i,x,y) for(long long i=(x),_b=(y);i>=_b;--i)
#define ii pair<long long,long long>
using namespace std;
const long long oo = 1e7 + 5;
const long long lim = 999999;
const long long mod = 1e9 + 7;

long long n, p, times;
long long a, b;
long long fir, snd;

map<long long, long long> cnt;

long long pw(long long a, long long b)
{
	if (b == 0) return (1 + mod*mod) % mod;
	if (b == 1) return (a + mod*mod) % mod;
	long long res = pow(a, b / 2);
	res = (res*res + mod*mod) % mod;

	if (b & 1) return (res*a + mod*mod) % mod; else return (res + mod*mod) % mod;
}

signed main()
{
	/*Coding or to be coded*/

	cin >> n;
	forto(i, 1, n)
	{
		cin >> p; cnt[p]++;
	}

	long long d = 1;
	long long ans = 1;
	for (auto x : cnt) {
		long long cnt = x.second;
		long long p = x.first;
		long long fp = pw(p, (cnt + 1) * cnt / 2);
		ans = pw(ans, (cnt + 1)) * pw(fp, d) % mod;
		d = d * (x.second + 1) % (mod - 1);
	}
	cout << ans << endl;

	/*When you want to give up,which cause make you start*/

	/*If you stop,you stilong long go alone*/
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)

const int N = 2e5+5;
const int mod = 1e9+7;

int cnt[N], a[N];

int power(int a, ll b){
    a = a % mod;
    int res = 1;
    while(b > 0){
        if(b & 1){
            res = res * 1ll * a % mod;
            b--;
        }
        a = a * 1ll * a % mod;
        b >>= 1;
    }
    return res;
}

void solve(){

    int m; cin >> m;
    int n = 1;
    memset(cnt, 0, sizeof(cnt));
    for(int i = 0; i < m; i++){
        cin >> a[i];
        cnt[a[i]]++;
    }
    int product = 1;
    int sum = 1;
    for(int i = 2; i < N; i++){
        if(cnt[i] > 0){
            int fp = power(i, cnt[i]  * 1ll * (cnt[i] + 1) / 2);
            product = power(product, cnt[i] + 1) * 1ll * power(fp, sum) % mod;
            sum = sum * 1ll * (cnt[i] + 1) % (mod - 1);
        }
    }
    cout << product << '\n';

}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    boost;

    int t = 1;
    // cin >> t;

    for(int i = 1; i <= t; i++){
        // cout << "Case #" << i << ": ";

        solve();

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)

const int N = 2e5+5;
const int mod = 1e9+7;

int cnt[N], a[N];

int power(int a, ll b, int mod){
    a = a % mod;
    int res = 1;
    while(b > 0){
        if(b & 1){
            res = res * 1ll * a % mod;
            b--;
        }
        a = a * 1ll * a % mod;
        b >>= 1;
    }
    return res;
}

void solve(){

    int m; cin >> m;
    int n = 1;
    memset(cnt, 0, sizeof(cnt));
    for(int i = 0; i < m; i++){
        cin >> a[i];
        cnt[a[i]]++;
    }
    bool isPerfect = true;
    int product = 1;
    int sum = 1;
    for(int i = 2; i < N; i++){
        if(cnt[i] % 2 != 0) isPerfect = false;
        if(cnt[i] > 0){
            int fp = power(i, cnt[i]  * 1ll * (cnt[i] + 1) / 2, mod - 1);
            product = power(product, (cnt[i] + 1), mod - 1) * 1ll * power(fp, sum, mod - 1) % mod;
            sum = sum * (cnt[i] + 1) % (mod - 1);
        }
    }
    if(isPerfect){
        for(int i = 2; i < N; i++){
            product = product * 1ll * power(i, cnt[i] / 2, mod - 1) % mod;
        }
    }
    cout << product << '\n';

}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    boost;

    int t = 1;
    // cin >> t;

    for(int i = 1; i <= t; i++){
        // cout << "Case #" << i << ": ";

        solve();

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)

const int N = 2e5+5;
const int mod = 1e9+7;

int cnt[N], a[N];

int power(int a, ll b){
    a = a % mod;
    int res = 1;
    while(b > 0){
        if(b & 1){
            res = res * 1ll * a % mod;
            b--;
        }
        a = a * 1ll * a % mod;
        b >>= 1;
    }
    return res;
}

void solve(){

    int m; cin >> m;
    int n = 1;
    memset(cnt, 0, sizeof(cnt));
    for(int i = 0; i < m; i++){
        cin >> a[i];
        cnt[a[i]]++;
    }
    bool isPerfect = true;
    int product = 1;
    int sum = 1;
    for(int i = 2; i < N; i++){
        if(cnt[i] % 2 != 0) isPerfect = false;
        if(cnt[i] > 0){
            int fp = power(i, cnt[i]  * 1ll * (cnt[i] + 1) / 2);
            product = power(product, (cnt[i] + 1)) * 1ll * power(fp, sum) % mod;
            sum = sum * (cnt[i] + 1) % (mod - 1);
        }
    }
    if(isPerfect){
        for(int i = 2; i < N; i++){
            product = product * 1ll * power(i, cnt[i] / 2) % mod;
        }
    }
    cout << product << '\n';

}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    boost;

    int t = 1;
    // cin >> t;

    for(int i = 1; i <= t; i++){
        // cout << "Case #" << i << ": ";

        solve();

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)

const int N = 2e5+5;
const int mod = 1e9+7;

int cnt[N], a[N];

int power(int a, ll b, int mod){
    a = a % mod;
    int res = 1;
    while(b > 0){
        if(b & 1){
            res = res * 1ll * a % mod;
            b--;
        }
        a = a * 1ll * a % mod;
        b >>= 1;
    }
    return res;
}

void solve(){

    int m; cin >> m;
    int n = 1;
    memset(cnt, 0, sizeof(cnt));
    for(int i = 0; i < m; i++){
        cin >> a[i];
        cnt[a[i]]++;
    }
    bool isPerfect = true;
    int product = 1;
    int sum = 1;
    for(int i = 2; i < N; i++){
        if(cnt[i] % 2 != 0) isPerfect = false;
        if(cnt[i] > 0){
            int fp = power(i, (cnt[i]  * 1ll * (cnt[i] + 1) / 2), mod - 1) % mod;
            product = power(product, (cnt[i] + 1), mod - 1) * 1ll * power(fp, sum, mod - 1) % mod;
            sum = sum * (cnt[i] + 1) % (mod - 1);
        }
    }
    if(isPerfect){
        for(int i = 2; i < N; i++){
            product = product * 1ll * power(i, cnt[i] / 2, mod - 1) % mod;
        }
    }
    cout << product << '\n';

}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    boost;

    int t = 1;
    // cin >> t;

    for(int i = 1; i <= t; i++){
        // cout << "Case #" << i << ": ";

        solve();

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)

const int N = 2e5+5;
const int mod = 1e9+7;

int cnt[N], a[N];

int power(int a, ll b, int mod){
    a = a % mod;
    int res = 1;
    while(b > 0){
        if(b & 1){
            res = res * 1ll * a % mod;
            b--;
        }
        a = a * 1ll * a % mod;
        b >>= 1;
    }
    return res;
}

void solve(){

    int m; cin >> m;
    int n = 1;
    memset(cnt, 0, sizeof(cnt));
    for(int i = 0; i < m; i++){
        cin >> a[i];
        cnt[a[i]]++;
    }
    bool isPerfect = true;
    int product = 1;
    int sum = 1;
    for(int i = 2; i < N; i++){
        if(cnt[i] % 2 != 0) isPerfect = false;
        if(cnt[i] > 0){
            int fp = power(i, (cnt[i]  * 1ll * (cnt[i] + 1) / 2), mod - 1) % mod;
            product = power(product, (cnt[i] + 1), mod - 1) * 1ll * power(fp, sum, mod - 1) % mod;
            sum = sum * (cnt[i] + 1) % (mod - 1);
        }
    }
    if(isPerfect){
        for(int i = 2; i < N; i++){
            product = product * 1ll * power(i, cnt[i] / 2, mod) % mod;
        }
    }
    cout << product << '\n';

}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    boost;

    int t = 1;
    // cin >> t;

    for(int i = 1; i <= t; i++){
        // cout << "Case #" << i << ": ";

        solve();

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)

const int N = 2e5+5;
const int mod = 1e9+7;

int cnt[N], a[N];

int power(int a, ll b){
    a = a % mod;
    int res = 1;
    while(b > 0){
        if(b & 1){
            res = res * 1ll * a % mod;
            b--;
        }
        a = a * 1ll * a % mod;
        b >>= 1;
    }
    return res;
}

void solve(){

    int m; cin >> m;
    int n = 1;
    memset(cnt, 0, sizeof(cnt));
    for(int i = 0; i < m; i++){
        cin >> a[i];
        cnt[a[i]]++;
    }
    int product = 1;
    int sum = 1;
    for(int i = 2; i < N; i++){
        if(cnt[i] > 0){
            int fp = power(i, cnt[i]  * 1ll * (cnt[i] + 1) / 2);
            product = power(product, cnt[i] + 1) * 1ll * power(fp, sum) % mod;
            sum = sum * (cnt[i] + 1) % (mod - 1);
        }
    }
    cout << product << '\n';

}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    boost;

    int t = 1;
    // cin >> t;

    for(int i = 1; i <= t; i++){
        // cout << "Case #" << i << ": ";

        solve();

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long Pow[200005];
long long num[200005];
set<long long> inp;
long long POW(long long base, long long n,long long check){
	long long stt=base;
	long long anss=1;
	//cout << base << " " << n <<endl;
	while(n){
		if(n%2==1){
			anss=(anss*base)%mod;
		}
		base= (base*base)%mod;
		n/=2;
	}
	if(check==1){
		return anss;
	}
	Pow[stt]=anss;
}
signed main(){
	long long m;
	cin >> m;
	long long ans=1;
	memset(Pow,0,sizeof(Pow));
	memset(num,0,sizeof(num));
	for(int i=1;i<=m;i++){
		long long a;
		cin >> a;
		num[a]++;
		inp.insert(a);
	}
	long long nummod=0;
	long long Base=1;
	for(auto x: inp){
		Base=(Base*(num[x]+1));
		nummod=nummod*(num[x]+1);
		while(Base>mod){
			long long d=Base%mod;
			long long e=(Base-d)/mod;
			Base=d;
			nummod+=e;
		}
		nummod=nummod%mod;
	}
	//cout << POW(2,3,1)<< " " << POW(2,3*mod,1);
	long long spec=POW(2,mod-2,1);
	for(auto x:inp){
		if(Pow[x]==0){
			long long BASE=((nummod*mod+Base)*num[x]);
			long long e=(Base*num[x])%mod;
			long long d=(nummod*num[x]+(Base*num[x]-e)/mod);
			if(e%2==1){
				d=(d+mod)/2;
			}
			else{
				d/=2;
			}
			e/=2;
			BASE=e+d;
			//cout << nummod*num[x]/2<< " " << Base*num[x]/2<<endl;
			//cout << BASE<<" " << d << " " << e <<endl;
			POW(x,BASE,0);
			//cout << BASE<<endl;
			//cout << POW(x,BASE,1)<<endl;
			//cout << POW(x,3,1)<< " " << POW(x,mod*2+1,1)<<endl;
		}
		ans=(ans*Pow[x])%mod;
	}
	cout << ans; //" " << Base;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long Pow[200005];
long long num[200005];
set<long long> inp;
void POW(long long base, long long n){
	long long stt=base;
	long long anss=1;
	//cout << base << " " << n <<endl;
	while(n){
		if(n%2==1){
			anss=(anss*base)%mod;
		}
		base= (base*base)%mod;
		n/=2;
	}
	Pow[stt]=anss;
}
signed main(){
	long long m;
	cin >> m;
	long long ans=1;
	memset(Pow,0,sizeof(Pow));
	memset(num,0,sizeof(num));
	for(int i=1;i<=m;i++){
		long long a;
		cin >> a;
		num[a]++;
		inp.insert(a);
	}
	long long cnt=0;
	long long Base=1;
	for(auto x: inp){
		Base=(Base*(num[x]+1))%mod;
		if(cnt==0&&Base%2==0){
			Base/=2;
			cnt=1;
		}
	}
	for(auto x:inp){
		if(Pow[x]==0){
			long long BASE=(Base*num[x])%mod;
			POW(x,BASE);
		}
		ans=(ans*Pow[x])%mod;
	}
	cout << ans;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long Pow[200005];
long long num[200005];
set<long long> inp;
void POW(long long base, long long n){
	long long stt=base;
	long long anss=1;
	//cout << base << " " << n <<endl;
	while(n){
		if(n%2==1){
			anss=(anss*base)%mod;
		}
		base= (base*base)%mod;
		n/=2;
	}
	Pow[stt]=anss;
}
signed main(){
	long long m;
	cin >> m;
	long long ans=1;
	memset(Pow,0,sizeof(Pow));
	memset(num,0,sizeof(num));
	for(int i=1;i<=m;i++){
		long long a;
		cin >> a;
		num[a]++;
		inp.insert(a);
	}
	long long nummod=0;
	long long Base=1;
	for(auto x: inp){
		Base=(Base*(num[x]+1));
		nummod=nummod*(num[x]+1);
		while(Base>mod){
			long long d=Base%mod;
			long long e=(Base-d)/mod;
			Base=d;
			nummod+=e;
		}
		nummod=nummod%mod;
	}
	for(auto x:inp){
		if(Pow[x]==0){
			long long BASE=((nummod*mod+Base)*num[x]);
			long long e=(Base*num[x])%mod;
			long long d=(nummod*num[x]+(Base*num[x]-e)/mod);
			if(e%2==1){
				d=(d+mod)/2;
			}
			else{
				d/=2;
			}
			e/=2;
			BASE=e+d;
			//cout << nummod*num[x]/2<< " " << Base*num[x]/2<<endl;
			//cout << BASE<<" " << d << " " << e <<endl;
			POW(x,BASE);
			//cout << BASE<<endl;
			//cout << POW(x,BASE,1)<<endl;
			//cout << POW(x,3,1)<< " " << POW(x,mod*2+1,1)<<endl;
		}
		ans=(ans*Pow[x])%mod;
	}
	cout << ans; //" " << Base;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long Pow[200005];
long long num[200005];
set<long long> inp;
void POW(long long base, long long n){
	long long stt=base;
	long long anss=1;
	//cout << base << " " << n <<endl;
	while(n){
		if(n%2==1){
			anss=(anss*base)%mod;
		}
		base= (base*base)%mod;
		n/=2;
	}
	Pow[stt]=anss;
}
signed main(){
	long long m;
	cin >> m;
	long long ans=1;
	memset(Pow,0,sizeof(Pow));
	memset(num,0,sizeof(num));
	for(int i=1;i<=m;i++){
		long long a;
		cin >> a;
		num[a]++;
		inp.insert(a);
	}
	long long Base=1;
	for(auto x: inp){
		Base=(Base*(num[x]+1))%mod;
	}
	for(auto x:inp){
		if(Pow[x]==0){
			long long BASE=(Base*num[x]/2)%mod;
			POW(x,BASE);
		}
		ans=(ans*Pow[x])%mod;
	}
	cout << ans;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long Pow[200005];
long long num[200005];
set<long long> inp;
long long POW(long long base, long long n,long long check){
	long long stt=base;
	long long anss=1;
	//cout << base << " " << n <<endl;
	while(n){
		if(n%2==1){
			anss=(anss*base)%mod;
		}
		base= (base*base)%mod;
		n/=2;
	}
	if(check==1){
		return anss;
	}
	Pow[stt]=anss;
}
signed main(){
	long long m;
	cin >> m;
	long long ans=1;
	memset(Pow,0,sizeof(Pow));
	memset(num,0,sizeof(num));
	for(int i=1;i<=m;i++){
		long long a;
		cin >> a;
		num[a]++;
		inp.insert(a);
	}
	long long nummod=0;
	long long Base=1;
	for(auto x: inp){
		Base=(Base*(num[x]+1));
		nummod=nummod*(num[x]+1);
		while(Base>mod){
			long long d=Base%mod;
			long long e=(Base-d)/mod;
			Base=d;
			nummod+=e;
		}
	}
	//cout << POW(2,3,1)<< " " << POW(2,3*mod,1);
	long long spec=POW(2,mod-2,1);
	for(auto x:inp){
		if(Pow[x]==0){
			long long BASE=((nummod*mod+Base)*num[x]);
			long long e=(Base*num[x])%mod;
			long long d=(nummod*num[x]+(Base*num[x]-e)/mod);
			if(e%2==1){
				d=(d+mod)/2;
			}
			else{
				d/=2;
			}
			e/=2;
			BASE=e+d;
			//cout << nummod*num[x]/2<< " " << Base*num[x]/2<<endl;
			//cout << BASE<<" " << d << " " << e <<endl;
			POW(x,BASE,0);
			//cout << BASE<<endl;
			//cout << POW(x,BASE,1)<<endl;
			//cout << POW(x,3,1)<< " " << POW(x,mod*2+1,1)<<endl;
		}
		ans=(ans*Pow[x])%mod;
	}
	cout << ans; //" " << Base;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long Pow[200005];
long long num[200005];
set<long long> inp;
long long POW(long long base, long long n,long long check){
	long long stt=base;
	long long anss=1;
	//cout << base << " " << n <<endl;
	while(n){
		if(n%2==1){
			anss=(anss*base)%mod;
		}
		base= (base*base)%mod;
		n/=2;
	}
	if(check==1){
		return anss;
	}
	Pow[stt]=anss;
}
signed main(){
	long long m;
	cin >> m;
	long long ans=1;
	memset(Pow,0,sizeof(Pow));
	memset(num,0,sizeof(num));
	for(int i=1;i<=m;i++){
		long long a;
		cin >> a;
		num[a]++;
		inp.insert(a);
	}
	long long Base=1;
	for(auto x: inp){
		Base=(Base*(num[x]+1));
		//while(Base>mod){
		//	long long d=Base%mod;
		//	long long e=(Base-d)/mod;
		//	Base=e+d;
		//}
	}
	//cout << POW(2,3,1)<< " " << POW(2,3*mod,1);
	long long spec=POW(2,mod-2,1);
	for(auto x:inp){
		if(Pow[x]==0){
			long long BASE=(Base*num[x]);
			long long d=BASE%mod;
			long long e=(BASE-d)/mod;
			if(e%2==1){
				d=(d+mod)/2;
			}
			else{
				d/=2;
			}
			e/=2;
			BASE=e+d;
			cout << BASE<<" " << d << " " << e <<endl;
			POW(x,BASE,0);
			//cout << BASE<<endl;
			//cout << POW(x,BASE,1)<<endl;
			//cout << POW(x,3,1)<< " " << POW(x,mod*2+1,1)<<endl;
		}
		ans=(ans*Pow[x])%mod;
	}
	cout << ans; //" " << Base;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long num[200005];
set<long long> inp;
long long POW(long long base, long long n){
	long long stt=base;
	long long anss=1;
	//cout << base << " " << n <<endl;
	while(n){
		if(n%2==1){
			anss=(anss*base)%mod;
		}
		base= (base*base)%mod;
		n/=2;
	}
	return anss;
}
signed main(){
	long long m;
	cin >> m;
	long long ans=1;
	memset(num,0,sizeof(num));
	for(int i=1;i<=m;i++){
		long long a;
		cin >> a;
		num[a]++;
		inp.insert(a);
	}
	long long d=1;
	for(auto x: inp){
		long long cnt= num[x];
		long long p= x;
		long long lol= POW(p, (cnt+1)*cnt/2);
		ans = POW(ans,cnt+1)*POW(lol,d)%mod;
		d=d*(num[x]+1)%(mod-1);
	}
	cout << ans;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long Pow[200005];
long long num[200005];
set<long long> inp;
long long POW(long long base, long long n,long long check){
	long long stt=base;
	long long anss=1;
	//cout << base << " " << n <<endl;
	while(n){
		if(n%2==1){
			anss=(anss*base)%mod;
		}
		base= (base*base)%mod;
		n/=2;
	}
	if(check==1){
		return anss;
	}
	Pow[stt]=anss;
}
signed main(){
	long long m;
	cin >> m;
	long long ans=1;
	memset(Pow,0,sizeof(Pow));
	memset(num,0,sizeof(num));
	for(int i=1;i<=m;i++){
		long long a;
		cin >> a;
		num[a]++;
		inp.insert(a);
	}
	long long Base=1;
	for(auto x: inp){
		Base=(Base*(num[x]+1));
		//while(Base>mod){
		//	long long d=Base%mod;
		//	long long e=(Base-d)/mod;
		//	Base=e+d;
		//}
	}
	//cout << POW(2,3,1)<< " " << POW(2,3*mod,1);
	long long spec=POW(2,mod-2,1);
	for(auto x:inp){
		if(Pow[x]==0){
			long long BASE=(Base*num[x]);
			long long d=BASE%mod;
			long long e=(BASE-d)/mod;
			if(e%2==1){
				d=(d+mod)/2;
			}
			e/=2;
			BASE=e+d;
			//cout << BASE<<" " << d << " " << e <<endl;
			POW(x,BASE,0);
			//cout << BASE<<endl;
			//cout << POW(x,BASE,1)<<endl;
			//cout << POW(x,3,1)<< " " << POW(x,mod*2+1,1)<<endl;
		}
		ans=(ans*Pow[x])%mod;
	}
	cout << ans; //" " << Base;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long Pow[200005];
long long num[200005];
set<long long> inp;
long long POW(long long base, long long n,long long check){
	long long stt=base;
	long long anss=1;
	//cout << base << " " << n <<endl;
	while(n){
		if(n%2==1){
			anss=(anss*base)%mod;
		}
		base= (base*base)%mod;
		n/=2;
	}
	if(check==1){
		return anss;
	}
	Pow[stt]=anss;
}
signed main(){
	long long m;
	cin >> m;
	long long ans=1;
	memset(Pow,0,sizeof(Pow));
	memset(num,0,sizeof(num));
	for(int i=1;i<=m;i++){
		long long a;
		cin >> a;
		num[a]++;
		inp.insert(a);
	}
	long long Base=1;
	for(auto x: inp){
		Base=(Base*(num[x]+1));
		//while(Base>mod){
		//	long long d=Base%mod;
		//	long long e=(Base-d)/mod;
		//	Base=e+d;
		//}
	}
	//cout << POW(2,3,1)<< " " << POW(2,3*mod,1);
	long long spec=POW(2,mod-2,1);
	for(auto x:inp){
		if(Pow[x]==0){
			long long BASE=(Base*num[x]);
			long long d=BASE%mod;
			long long e=(BASE-d)/mod;
			if(e%2==1){
				d=(d+mod)/2;
			}
			else{
				d/=2;
			}
			e/=2;
			BASE=e+d;
			//cout << BASE<<" " << d << " " << e <<endl;
			POW(x,BASE,0);
			//cout << BASE<<endl;
			//cout << POW(x,BASE,1)<<endl;
			//cout << POW(x,3,1)<< " " << POW(x,mod*2+1,1)<<endl;
		}
		ans=(ans*Pow[x])%mod;
	}
	cout << ans; //" " << Base;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long Pow[200005];
long long num[200005];
set<long long> inp;
void POW(long long base, long long n){
	long long stt=base;
	long long anss=1;
	//cout << base << " " << n <<endl;
	while(n){
		if(n%2==1){
			anss=(anss*base)%mod;
		}
		base= (base*base)%mod;
		n/=2;
	}
	Pow[stt]=anss;
}
signed main(){
	long long m;
	cin >> m;
	long long ans=1;
	memset(Pow,0,sizeof(Pow));
	memset(num,0,sizeof(num));
	for(int i=1;i<=m;i++){
		long long a;
		cin >> a;
		num[a]++;
		inp.insert(a);
	}
	long long Base=1;
	for(auto x: inp){
		Base=Base*(num[x]+1);
	}
	for(auto x:inp){
		if(Pow[x]==0){
			long long BASE=Base*num[x]/2;
			POW(x,BASE);
		}
		ans=(ans*Pow[x])%mod;
	}
	cout << ans;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long Pow[200005];
void POW(long long base, long long n){
	long long stt=base;
	long long anss=1;
	//cout << base << " " << n <<endl;
	while(n){

		if(n%2==1){
			anss=(anss*base)%mod;
		}
		base= (base*base)%mod;
		n/=2;
	}
	Pow[stt]=anss;
}
signed main(){
	long long m;
	cin >> m;
	long long ans=1;
	memset(Pow,0,sizeof(Pow));
	for(int i=1;i<=m;i++){
		long long a;
		cin >> a;
		if(Pow[a]==0){
			POW(a,m);
		}
		ans=(ans*Pow[a])%mod;
	}
	cout << ans;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long Pow[200005];
void POW(long long base, long long n){
	long long stt=base;
	long long anss=1;
	//cout << base << " " << n <<endl;
	while(n){
		if(n%2==1){
			anss=(anss*base)%mod;
		}
		base= (base*base)%mod;
		n/=2;
	}
	Pow[stt]=anss;
}
signed main(){
	long long m;
	cin >> m;
	long long ans=1;
	memset(Pow,0,sizeof(Pow));
	for(int i=1;i<=m;i++){
		long long a;
		cin >> a;
		if(Pow[a]==0){
			POW(a,m);
		}
		ans=(ans*Pow[a])%mod;
	}
	cout << ans;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long Pow[200005];
long long num[200005];
set<long long> inp;
long long POW(long long base, long long n,long long check){
	long long stt=base;
	long long anss=1;
	//cout << base << " " << n <<endl;
	while(n){
		if(n%2==1){
			anss=(anss*base)%mod;
		}
		base= (base*base)%mod;
		n/=2;
	}
	if(check==1){
		return anss;
	}
	Pow[stt]=anss;
}
signed main(){
	long long m;
	cin >> m;
	long long ans=1;
	memset(Pow,0,sizeof(Pow));
	memset(num,0,sizeof(num));
	for(int i=1;i<=m;i++){
		long long a;
		cin >> a;
		num[a]++;
		inp.insert(a);
	}
	long long Base=1;
	for(auto x: inp){
		Base=(Base*(num[x]+1))%mod;
	}
	long long spec=POW(2,mod-2,1);
	for(auto x:inp){
		if(Pow[x]==0){
			long long BASE=(Base*num[x]*spec)%mod;
			POW(x,BASE,0);
		}
		ans=(ans*Pow[x])%mod;
	}
	cout << ans;
}


/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
#define sz(v) (int)v.size()
#define endl '\n'
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
const int N = 3e4+5;
const int mod = 1e9 + 7;

int32_t main()
{

  speed_cubing

  int m;
  cin>>m;

  int a[m];

  for(int i=0;i<m;i++)
    cin>>a[i];

  map<int,int> h;

  for(int i=0;i<m;i++)
    h[a[i]]++;

  vector<int> v;

  for(auto x:h)
    v.pb(x.ff);

  int n = v.size();

  int dp1[n],dp2[n];

  int ans = 1;

  for(int i=0;i<n;i++){
      dp1[i] = (ans*(h[v[i]]+1))%(mod-1);
      ans = dp1[i];
  }

  ans = 1;

  for(int i=n-1;i>=0;i--){
      dp2[i] = (ans*(h[v[i]]+1))%(mod-1);
      ans = dp2[i];
  }

  ans = 1;

  for(int i=0;i<n;i++){

      int temp = 1;

      for(int j=0;j<h[v[i]];j++){
         int p = ( (i>0 ? dp1[i-1] : 0)+(i<n-1 ? dp2[i+1] : 0) )%mod;
         int t = (temp*( p == 0 ? 1 : p ) )%(mod-1);
         ans = (ans*powmod(v[i],t,mod))%mod;
         temp++;
      }

  }

  cout<<ans;

  return 0;
}


/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
#define sz(v) (int)v.size()
#define endl '\n'
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
const int N = 3e4+5;
const int mod = 1e9 + 7;

int32_t main()
{

  speed_cubing

  int m;
  cin>>m;

  int a[m];

  for(int i=0;i<m;i++)
    cin>>a[i];

  map<int,int> h;

  for(int i=0;i<m;i++)
    h[a[i]]++;

  vector<int> v;

  for(auto x:h)
    v.pb(x.ff);

  int n = v.size();

  int dp1[n],dp2[n];

  int ans = 1;

  for(int i=0;i<n;i++){
      dp1[i] = (ans*(h[v[i]]+1))%(mod-1);
      ans = dp1[i];
  }

  ans = 1;

  for(int i=n-1;i>=0;i--){
      dp2[i] = (ans*(h[v[i]]+1))%(mod-1);
      ans = dp2[i];
  }

  ans = 1;

  for(int i=0;i<n;i++){

      int temp = 1;

      for(int j=0;j<h[v[i]];j++){
         int p = ( (i>0 ? dp1[i-1] : 0)+(i<n-1 ? dp2[i+1] : 0) )%(mod-1);
         if(p==0)
           p = 1;
         int t = (temp*p)%(mod-1);
         ans = (ans*powmod(v[i],t,mod))%mod;
         temp++;
         temp%=(mod-1);
      }

  }

  cout<<ans;

  return 0;
}


/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
#define sz(v) (int)v.size()
#define endl '\n'
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
const int N = 3e4+5;
const int mod = 1e9 + 7;

int32_t main()
{

  speed_cubing

  int m;
  cin>>m;

  int a[m];

  for(int i=0;i<m;i++)
    cin>>a[i];

  map<int,int> h;

  for(int i=0;i<m;i++)
    h[a[i]]++;

  vector<int> v;

  for(auto x:h)
    v.pb(x.ff);

  int n = v.size();

  int dp1[n],dp2[n];

  int ans = 1;

  for(int i=0;i<n;i++){
      dp1[i] = (ans*(h[v[i]]+1))%(mod-1);
      ans = dp1[i];
  }

  ans = 1;

  for(int i=n-1;i>=0;i--){
      dp2[i] = (ans*(h[v[i]]+1))%(mod-1);
      ans = dp2[i];
  }

  ans = 1;

  for(int i=0;i<n;i++){

      int temp = 1;

      for(int j=0;j<h[v[i]];j++){
         int p = ( (i>0 ? dp1[i-1] : 0)+(i<n-1 ? dp2[i+1] : 0) )%(mod-1);
         int t = (temp*( p == 0 ? 1 : p ) )%(mod-1);
         ans = (ans*powmod(v[i],t,mod))%mod;
         temp++;
      }

  }

  cout<<ans;

  return 0;
}


/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
#define sz(v) (int)v.size()
#define endl '\n'
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
const int N = 3e4+5;
const int mod = 1e9 + 7;

int32_t main()
{

  speed_cubing

  int m;
  cin>>m;

  int a[m];

  for(int i=0;i<m;i++)
    cin>>a[i];

  map<int,int> h;

  for(int i=0;i<m;i++)
    h[a[i]]++;

  vector<int> v;

  for(auto x:h)
    v.pb(x.ff);

  int n = v.size();

  int dp1[n],dp2[n];

  int ans = 1;

  for(int i=0;i<n;i++){
      dp1[i] = (ans*(h[v[i]]+1))%(mod-1);
      ans = dp1[i];
  }

  ans = 1;

  for(int i=n-1;i>=0;i--){
      dp2[i] = (ans*(h[v[i]]+1))%(mod-1);
      ans = dp2[i];
  }

  ans = 1;

  for(int i=0;i<n;i++){

      int temp = 1;

      for(int j=0;j<h[v[i]];j++){
         int t = (temp*((i>0 ? dp1[i-1] : 0)+(i<n-1 ? dp2[i+1] : 0)))%(mod-1);
         ans = (ans*powmod(v[i],t,mod))%mod;
         temp++;
      }

  }

  cout<<ans;

  return 0;
}


/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
#define sz(v) (int)v.size()
#define endl '\n'
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
const int N = 3e4+5;
const int mod = 1e9+7;
set<vector<int> > s;

int rec(int n,int a[],int ind,vector<int> ans){

    if(ind==n){

         sort(ans.begin(),ans.end());

         int temp = 1;

         if(!s.count(ans)){
              for(auto x:ans)
                temp*=x,temp%=mod;
         }

         s.insert(ans);

         return temp;

    }

    vector<int> temp = ans;
    temp.pb(a[ind]);

    return ( rec(n,a,ind+1,temp)*rec(n,a,ind+1,ans) )%mod;

}

int32_t main()
{

  speed_cubing

  int m;
  cin>>m;

  int a[m];

  for(int i=0;i<m;i++)
    cin>>a[i];

  cout<<rec(m,a,0,{});

  return 0;

}


/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
#define sz(v) (int)v.size()
#define endl '\n'
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
const int N = 3e4+5;
const int mod = 1e9 + 7;

int32_t main()
{

  speed_cubing

  int m;
  cin>>m;

  int a[m];

  for(int i=0;i<m;i++)
    cin>>a[i];

  map<int,int> h;

  for(int i=0;i<m;i++)
    h[a[i]]++;

  vector<int> v;

  for(auto x:h)
    v.pb(x.ff);

  int n = v.size();

  int dp1[n],dp2[n];

  int ans = 1;

  for(int i=0;i<n;i++){
      dp1[i] = (ans*(h[v[i]]+1))%(mod-1);
      ans = dp1[i];
  }

  ans = 1;

  for(int i=n-1;i>=0;i--){
      dp2[i] = (ans*(h[v[i]]+1))%(mod-1);
      ans = dp2[i];
  }

  ans = 1;

  for(int i=0;i<n;i++){

      int temp = 1;

      for(int j=0;j<h[v[i]];j++){
         int p = ( (i>0 ? dp1[i-1] : 1)*(i<n-1 ? dp2[i+1] : 1) )%(mod-1);
         int t = (temp*p)%(mod-1);
         ans = (ans*powmod(v[i],t,mod))%mod;
         temp++;
         temp%=(mod-1);
      }

  }

  cout<<ans;

  return 0;
}


#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
ll MOD=1e9+7;
ll power(ll b,ll p)
{
    if(p==0)
        return 1;
    if(p&1ll)
        return (b%MOD*power((b*b)%MOD,p/2))%MOD;
    else
        return power((b*b)%MOD,p/2);
}
const int N=200009;
int n;
vector<int> v;
int cnt[N];

int main()
{

    cin>>n;
    int no;
    for(int i=0;i<n;i++)
    {
        cin>>no;
        cnt[no]++;
        if(cnt[no]==1)
            v.pb(no);
    }

    ll div=1;

    for(int i=0;i<sz(v);i++)
    {
        div=(div*(cnt[v[i]]+1))%MOD;
    }
    ll d=div/2;
    ll ans=1;
    for(int i=0;i<sz(v);i++)
    {
        ll c= (cnt[v[i]]*d)%(MOD-1);

        ans= (ans*(power(v[i],c)%MOD))%MOD;
    }

    if(div%2!=0)
    {
        for(int i=0;i<sz(v);i++)
       {
        ans=(ans*power(v[i],(cnt[v[i]]/2)))%MOD;
       }

    }

    cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask)     {mask &= (mask-1);++ret;    }return ret;}
const ll MOD=1e9+7;
const int N=200009;
int n;
pair<ll,int> mem[N];
vector<int> v;
int cnt[N];

ll power(ll b,ll p)
{
    if(p==0)
        return 1;
    if(p&1)
        return (b%MOD*power((b*b)%MOD,p/2))%MOD;
    else
        return power((b*b)%MOD,p/2)%MOD;
}

pair<ll,int> solve(int id)
{
    if(id==sz(v))
    {
        return mp(1,1);
    }

    pair<ll,int> ret=mem[id];

    if(ret.first!=-1)
        return ret;

    ll ans=solve(id+1).first;
    ll c=solve(id+1).second;
    for(int i=1;i<=cnt[v[id]];i++)
    {

        pair<ll,int> p=solve(id+1);
        c += p.second;
        c %= MOD-1;
        ll val=p.first;
        ll res=power(v[id],p.second*i % (MOD-1));

        ans= (ans*((res *val )%MOD))%MOD;
    }

    return mem[id]=mp(ans,c);

}

int main()
{

    cin>>n;
    int no;

    for(int i=0;i<n;i++)
    {
        cin>>no;
        cnt[no]++;
        if(cnt[no]==1)
        v.pb(no);

    }
    //cout<<cnt[2]<<endl;
    clr(mem,-1);
    ll ans=solve(0).first;
    cout <<ans;
}


#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
ll MOD=1e9+7;
ll power(ll b,ll p)
{
    if(p==0)
        return 1;
    if(p&1ll)
        return (b%MOD*power((b*b)%MOD,p/2))%MOD;
    else
        return power((b*b)%MOD,p/2);
}
const int N=200009;
int n;
vector<int> v;
int cnt[N];

int main()
{

    cin>>n;
    int no;
    for(int i=0;i<n;i++)
    {
        cin>>no;
        cnt[no]++;
        if(cnt[no]==1)
            v.pb(no);
    }

    ll div=1;

    for(int i=0;i<sz(v);i++)
    {
        div=(div*(cnt[v[i]]+1))%(MOD);
    }
    ll d=(div*(power(2,MOD-2)%MOD))%MOD;
    ll ans=1;
    for(int i=0;i<sz(v);i++)
    {
        ll c= (cnt[v[i]]*d)%(MOD-1);

        ans= (ans*(power(v[i],c)%MOD))%MOD;
    }

    if(div%2!=0)
    {
        for(int i=0;i<sz(v);i++)
       {
        ans=(ans*power(v[i],(cnt[v[i]]/2)))%MOD;
       }

    }

    cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
ll MOD=1e9+7;
ll power(ll b,ll p)
{
    if(p==0)
        return 1;
    if(p&1ll)
        return (b%MOD*power((b*b)%MOD,p/2))%MOD;
    else
        return power((b*b)%MOD,p/2);
}
const int N=200009;
int n;
vector<int> v;
int cnt[N];

int main()
{

    cin>>n;
    int no;
    for(int i=0;i<n;i++)
    {
        cin>>no;
        cnt[no]++;
        if(cnt[no]==1)
            v.pb(no);
    }
    bool ev=1;

    for(int i=0;i<sz(v);i++)
    {
        if(cnt[v[i]]%2!=0)
            ev=0;
    }

    ll div=1;

    for(int i=0;i<sz(v);i++)
    {
        div=(div*(cnt[v[i]]+1))%(MOD-1);
    }
    ll d=(div/2)%(MOD-1);
    ll ans=1;
    for(int i=0;i<sz(v);i++)
    {
        ll c= (cnt[v[i]]*d)%(MOD-1);

        ans= (ans*(power(v[i],c)%MOD))%MOD;
    }

    if(ev)
    {
        for(int i=0;i<sz(v);i++)
       {
        ans=(ans*power(v[i],(cnt[v[i]]/2)))%MOD;
       }

    }

    cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const ll MOD=1e9+7;
const int N=2009;
int n;
pair<ll,int> mem[N];
vector<int> v;
int cnt[N];
pair<ll,int> solve(int id)
{
    if(id==sz(v))
    {
        return mp(1,1);
    }
    pair<ll,int> ret=mem[id];
    if(ret.first!=-1)
        return ret;
    ll ans=1,p2;
    int c;
    for(int i=1;i<=cnt[v[id]];i++)
    {

        pair<ll,int> p=solve(id+1);
        c=p.second;
        ll val=p.first;
        ll res=pow(i*v[id],c);

        ans= (ans*(res *val )%MOD)%MOD;
    }

    return mem[id]=mp(ans,c+1);

}

int main()
{

    cin>>n;
    int no;

    for(int i=0;i<n;i++)
    {
        cin>>no;
        cnt[no]++;
        if(cnt[no]==1)
        v.pb(no);

    }
    //cout<<cnt[2]<<endl;
    clr(mem,-1);
    ll ans=solve(0).first;
    clr(mem,-1);
    ll ans2= solve(1).first;

    cout<<ans*ans2<<endl;
}


#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const ll MOD=1e9+7;
const int N=200009;
int n;
pair<ll,int> mem[N];
vector<int> v;
int cnt[N];

ll power(ll b,ll p)
{
    if(p==0)
        return 1;
    if(p&1)
        return (b%MOD*power((b*b)%MOD,p/2))%MOD;
    else
        return power((b*b)%MOD,p/2)%MOD;
}

pair<ll,int> solve(int id)
{
    if(id==sz(v))
    {
        return mp(1,1);
    }

    pair<ll,int> ret=mem[id];

    if(ret.first!=-1)
        return ret;

    ll ans=1;
    ll c;
    for(int i=1;i<=cnt[v[id]];i++)
    {

        pair<ll,int> p=solve(id+1);
        c=p.second;
        ll val=p.first;
        ll res=power(v[id],c*i);

        ans= (ans*((res *val )%MOD))%MOD;
    }

    return mem[id]=mp(ans,c+1);

}

int main()
{

    cin>>n;
    int no;

    for(int i=0;i<n;i++)
    {
        cin>>no;
        cnt[no]++;
        if(cnt[no]==1)
        v.pb(no);

    }
    //cout<<cnt[2]<<endl;
    clr(mem,-1);
    ll ans=solve(0).first;
    clr(mem,-1);
    ll ans2= solve(1).first;
    //cout<<ans2<<" "<<ans<<endl;
    cout<<(ans*ans2)%MOD<<endl;
}


#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=200009;
ll MOD=1e9+7;
int n;
int cnt[N];
vector< int > p;
ll power(ll b,ll p)
{
    if(p==0)
        return 1;
    if(p&1)
        return ((b)%MOD*power((b*b)%MOD,p/2))%MOD;
    else
        return power((b*b)%MOD,p/2);
}
int main()
{
    cin>>n;
    int no;
    for(int i=0;i<n;i++)
    {
        cin>>no;
        cnt[no]++;
        if(cnt[no]==1)
            p.pb(no);
    }
    ll ans=1;
    ll d=1;
    for(int i=0;i<sz(p);i++)
    {
        ll c=cnt[p[i]];
        ll curp= power(p[i],(c*(c+1))/2);
        ans= (power(curp,d)*power(ans,c+1))%MOD;
        d=(d+cnt[p[i]])%(MOD-1);
    }
    cout<<ans<<endl;

}


#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
ll MOD=1e9+7;
ll power(ll b,ll p)
{
    if(p==0)
        return 1;
    if(p&1ll)
        return (b%MOD*power((b*b)%MOD,p/2))%MOD;
    else
        return power((b*b)%MOD,p/2);
}
const int N=200009;
int n;
vector<int> v;
int cnt[N];

int main()
{

    cin>>n;
    int no;
    for(int i=0;i<n;i++)
    {
        cin>>no;
        cnt[no]++;
        if(cnt[no]==1)
            v.pb(no);
    }

    ll div=1;

    for(int i=0;i<sz(v);i++)
    {
        div=(div*(cnt[v[i]]+1))%(MOD-1);
    }
    ll d=(div/2)%(MOD-1);
    ll ans=1;
    for(int i=0;i<sz(v);i++)
    {
        ll c= (cnt[v[i]]*d)%(MOD-1);

        ans= (ans*(power(v[i],c)%MOD))%MOD;
    }

    if(div%2!=0)
    {
        for(int i=0;i<sz(v);i++)
       {
        ans=(ans*power(v[i],(cnt[v[i]]/2)))%MOD;
       }

    }

    cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const ll MOD=1e9+7;
const int N=200009;
int n;
pair<ll,int> mem[N];
vector<int> v;
int cnt[N];
pair<ll,int> solve(int id)
{
    if(id==sz(v))
    {
        return mp(1,1);
    }
    pair<ll,int> ret=mem[id];
    if(ret.first!=-1)
        return ret;
    ll ans=1,p2;
    int c;
    for(int i=1;i<=cnt[v[id]];i++)
    {

        pair<ll,int> p=solve(id+1);
        c=p.second;
        ll val=p.first;
        ll res=pow(i*v[id],c);

        ans= (ans*(res *val )%MOD)%MOD;
    }

    return mem[id]=mp(ans,c+1);

}

int main()
{

    cin>>n;
    int no;

    for(int i=0;i<n;i++)
    {
        cin>>no;
        cnt[no]++;
        if(cnt[no]==1)
        v.pb(no);

    }
    //cout<<cnt[2]<<endl;
    clr(mem,-1);
    ll ans=solve(0).first;
    clr(mem,-1);
    ll ans2= solve(1).first;

    cout<<(ans*ans2)%MOD<<endl;
}


#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
ll MOD=1e9+7,MOD2=MOD-1;
ll power(ll b,ll p)
{
    if(p==0)
        return 1;
    if(p&1ll)
        return (b%MOD*(power((b*b)%MOD,p/2)%MOD))%MOD;
    else
        return power((b*b)%MOD,p/2)%MOD;
}
ll power2(ll b,ll p)
{
    if(p==0)
        return 1;
    if(p&1ll)
        return (b%MOD2*(power((b*b)%MOD2,p/2)%MOD2))%MOD2;
    else
        return power((b*b)%MOD2,p/2)%MOD2;
}
const int N=200009;
int n;
vector<int> v;
int cnt[N];

int main()
{

    cin>>n;
    int no;

    if(n==1)
    {
        cin>>no;
        cout<<no<<endl;
        return 0;
    }
    for(int i=0;i<n;i++)
    {
        cin>>no;
        cnt[no]++;
        if(cnt[no]==1)
            v.pb(no);
    }
    bool ev=1;

    for(int i=0;i<sz(v);i++)
    {
        if(cnt[v[i]]%2!=0)
            ev=0;
    }

    ll div=1;

    for(int i=0;i<sz(v);i++)
    {
        div=(div*(cnt[v[i]]+1))%(MOD-1);
    }
    //cout<<div<<endl;
    ll d=(div*(power2(2,MOD-3))%MOD2)%(MOD-1);

    ll ans=1;
    for(int i=0;i<sz(v);i++)
    {
        ll c= (cnt[v[i]]*d)%(MOD-1);

        ans= (ans*(power(v[i],c)%MOD))%MOD;
    }

    if(ev)
    {
        for(int i=0;i<sz(v);i++)
       {
        ans=(ans*(power(v[i],(cnt[v[i]]/2))%MOD))%MOD;
       }

    }

    cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=200009;
ll MOD=1e9+7;
int n;
int cnt[N];
vector< int > p;
ll power(ll b,ll p)
{
    if(p==0)
        return 1;
    if(p&1)
        return ((b)%MOD*power((b*b)%MOD,p/2))%MOD;
    else
        return power((b*b)%MOD,p/2);
}
int main()
{
    cin>>n;
    int no;
    for(int i=0;i<n;i++)
    {
        cin>>no;
        cnt[no]++;
        if(cnt[no]==1)
            p.pb(no);
    }
    ll ans=1;
    ll d=1;
    for(int i=0;i<sz(p);i++)
    {
        ll c=cnt[p[i]];
        ll curp= power(p[i],(c*(c+1))/2);
        ans= (power(curp,d)*power(ans,c+1))%MOD;
        d=(d*(cnt[p[i]]+1))%(MOD-1);
    }
    cout<<ans<<endl;

}


#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask)     {mask &= (mask-1);++ret;    }return ret;}
const ll MOD=1e9+7;
const int N=200009;
int n;
pair<ll,ll> mem[N];
vector<ll> v;
ll cnt[N];

ll power(ll b,ll p)
{
    if(p==0)
        return 1;
    if(p&1ll)
        return (b%MOD*power((b*b)%MOD,p/2))%MOD;
    else
        return power((b*b)%MOD,p/2)%MOD;
}

pair<ll,ll> solve(int id)
{
    if(id==sz(v))
    {
        return mp(1,1);
    }

    pair<ll,ll> ret=mem[id];

    if(ret.first!=-1)
        return ret;

    ll ans=1;
    ll c=solve(id+1).second;
    for(int i=1;i<=cnt[v[id]];i++)
    {

        pair<ll,ll> p=solve(id+1);
        c =(c+ p.second)%(MOD-1);

        ll val=p.first;
        ll res=power(v[id],p.second*i % (MOD-1));

        ans= (val*((res *val )%MOD))%MOD;
    }

    return mem[id]=mp(ans,c);

}

int main()
{

    cin>>n;
    int no;

    for(int i=0;i<n;i++)
    {
        cin>>no;
        cnt[no]++;
        if(cnt[no]==1)
        v.pb(no);

    }
    //cout<<cnt[2]<<endl;
    clr(mem,-1);
    ll ans=solve(0).first;
    cout <<ans;
}


#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=200009;
ll MOD=1e9+7;
int n;
int cnt[N];
vector< int > p;
ll power(ll b,ll p)
{
    if(p==0)
        return 1;
    if(p&1)
        return ((b)%MOD*power((b*b)%MOD,p/2))%MOD;
    else
        return power((b*b)%MOD,p/2);
}
int main()
{
    cin>>n;
    int no;
    for(int i=0;i<n;i++)
    {
        cin>>no;
        cnt[no]++;
        if(cnt[no]==1)
            p.pb(no);
    }
    ll ans=1;
    ll d=1;
    for(int i=0;i<sz(p);i++)
    {
        int c=cnt[p[i]];
        ll curp= power(p[i],(c*(c+1))/2);
        ans= (power(curp,d)*power(ans,c+1))%MOD;
        d=(d+cnt[p[i]])%(MOD-1);
    }
    cout<<ans<<endl;

}


#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask)     {mask &= (mask-1);++ret;    }return ret;}
const ll MOD=1e9+7;
const int N=200009;
int n;
pair<ll,ll> mem[N];
vector<ll> v;
ll cnt[N];

ll power(ll b,ll p)
{
    if(p==0)
        return 1;
    if(p&1ll)
        return (b%MOD*power((b*b)%MOD,p/2))%MOD;
    else
        return power((b*b)%MOD,p/2)%MOD;
}

pair<ll,ll> solve(int id)
{
    if(id==sz(v))
    {
        return mp(1,1);
    }

    pair<ll,ll> ret=mem[id];

    if(ret.first!=-1)
        return ret;

    ll ans=solve(id+1).first;
    ll c=solve(id+1).second;
    for(int i=1;i<=cnt[v[id]];i++)
    {

        pair<ll,ll> p=solve(id+1);
        c =(c+ p.second)%(MOD-1);

        ll val=p.first;
        ll res=power(v[id],p.second*i % (MOD-1));

        ans= (ans*((res *val )%MOD))%MOD;
    }

    return mem[id]=mp(ans,c);

}

int main()
{

    cin>>n;
    int no;

    for(int i=0;i<n;i++)
    {
        cin>>no;
        cnt[no]++;
        if(cnt[no]==1)
        v.pb(no);

    }
    //cout<<cnt[2]<<endl;
    clr(mem,-1);
    ll ans=solve(0).first;
    cout <<ans;
}


#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
ll MOD=1e9+7,MOD2=MOD-1;
ll power(ll b,ll p)
{
    if(p==0)
        return 1;
    if(p&1ll)
        return (b%MOD*(power((b*b)%MOD,p/2)%MOD))%MOD;
    else
        return power((b*b)%MOD,p/2)%MOD;
}
ll power2(ll b,ll p)
{
    if(p==0)
        return 1;
    if(p&1ll)
        return (b%MOD2*(power((b*b)%MOD2,p/2)%MOD2))%MOD2;
    else
        return power((b*b)%MOD2,p/2)%MOD2;
}
const int N=200009;
int n;
vector<int> v;
int cnt[N];

int main()
{

    cin>>n;
    int no;

    for(int i=0;i<n;i++)
    {
        cin>>no;
        cnt[no]++;
        if(cnt[no]==1)
            v.pb(no);
    }
    bool ev=1;

    for(int i=0;i<sz(v);i++)
    {
        if(cnt[v[i]]%2!=0)
            ev=0;
    }

    ll div=1;

    for(int i=0;i<sz(v);i++)
    {
        div=(div*(cnt[v[i]]+1));
    }
    //cout<<div<<endl;
    ll d=(div/2);

    ll ans=1;
    for(int i=0;i<sz(v);i++)
    {
        ll c= (cnt[v[i]]*d)%(MOD-1);

        ans= (ans*(power(v[i],c)%MOD))%MOD;
    }

    if(ev)
    {
        for(int i=0;i<sz(v);i++)
       {
        ans=(ans*(power(v[i],(cnt[v[i]]/2))%MOD))%MOD;
       }

    }

    cout<<ans<<endl;
}