D. Multipliers
time limit per test
2 secondsmemory limit per test
256 megabytesinput
standard inputoutput
standard outputAyrat has number n, represented as it's prime factorization pi of size m, i.e. n = p1·p2·...·pm. Ayrat got secret information that that the product of all divisors of n taken modulo 109 + 7 is the password to the secret data base. Now he wants to calculate this value.
Input
The first line of the input contains a single integer m (1 ≤ m ≤ 200 000) — the number of primes in factorization of n.
The second line contains m primes numbers pi (2 ≤ pi ≤ 200 000).
Output
Print one integer — the product of all divisors of n modulo 109 + 7.
Examples
Input
2
2 3
Output
36
Input
3
2 3 2
Output
1728
Note
In the first sample n = 2·3 = 6. The divisors of 6 are 1, 2, 3 and 6, their product is equal to 1·2·3·6 = 36.
In the second sample 2·3·2 = 12. The divisors of 12 are 1, 2, 3, 4, 6 and 12. 1·2·3·4·6·12 = 1728.
1 #pragma comment(linker, "/STACK:102400000,102400000") 2 #include <cstdio> 3 #include <iostream> 4 #include <cstdlib> 5 #include <cstring> 6 #include <algorithm> 7 #include <cmath> 8 #include <cctype> 9 #include <map> 10 #include <set> 11 #include <queue> 12 #include <bitset> 13 #include <string> 14 #include <complex> 15 #define ll __int64 16 #define mod 1000000007 17 using namespace std; 18 int m; 19 map<int,ll> mp; 20 ll a[200005]; 21 ll quickpow(ll a,ll b) 22 { 23 ll re=1; 24 while(b>0) 25 { 26 if(b%2==1) 27 re=(re*a)%mod; 28 b/=2; 29 a=(a*a)%mod; 30 } 31 return re%mod; 32 } 33 int main(){ 34 scanf("%d",&m); 35 int jishu=0; 36 ll exm; 37 ll ans=1; 38 for(int i=1; i<=m; i++){ 39 scanf("%I64d",&exm); 40 if(mp[exm]==0){ 41 a[jishu++]=exm; 42 } 43 mp[exm]++; 44 } 45 ll re=1; 46 for(int i=0;i<jishu;i++) 47 re=re*(mp[a[i]]+1)%(2*(mod-1)); 48 for(int i=0;i<jishu;i++) 49 ans=ans*quickpow(a[i],(re*mp[a[i]]/2)%(mod-1))%mod; 50 printf("%I64d ",ans); 51 return 0; 52 }