#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define F1(x,y,z) for(int x=y;xz;x--) #define F4(x,y,z) for(int x=y;x>=z;x--) #define pb push_back #define LL long long #define co complex #define MAX 100005 #define AMAX 1500 #define MOD 1000000007 #define f(c,d) ((1<<(c))*(d)) using namespace std; int n,ta,tt; LL tb,tc; map x; map::iterator it; vector prime; vector pro; bool ok; LL po(LL b,LL p){ if(!p)return 1; if(p&1)return b*po(b,p-1)%MOD; LL t=po(b,p>>1); return t*t%MOD; } int main(){ F1(a,2,MAX){ if(a*a>MAX)break; ok=1; F1(b,0,prime.size()){ if(prime[b]*prime[b]>a)break; if(a%prime[b]==0){ ok=0; break; } } if(ok)prime.pb(a); } while(scanf("%d",&n)==1){ x.clear(); scanf("%d",&ta); F2(a,2,n){ tt=a; scanf("%d",&ta); F1(b,0,prime.size()){ if(prime[b]*prime[b]>tt)break; if(tt%prime[b]==0){ it=x.insert(make_pair(prime[b],0LL)).first; while(tt%prime[b]==0){ tt/=prime[b]; it->second+=ta; } } } if(tt!=1)x[tt]+=ta; } ok=1; pro.clear(); pro.pb(1LL); for(it=x.begin();it!=x.end();++it){ tb=it->second+1; if(tb%2==0&&ok){ tb/=2; ok=0; } pro.back()=pro.back()*tb%(MOD-1); } tb=1; for(it=x.begin();it!=x.end();++it){ if(ok)tc=po(it->first,it->second/2); else tc=po(it->first,it->second); F1(a,0,pro.size())tc=po(tc,pro[a]); tb=tb*tc%MOD; } printf("%I64d\n",tb); } //system("pause"); return 0; }