import sys input = sys.stdin.readline mod=10**9+7 def fact(x): L=int(x**(1/2)) FACT=dict() for i in range(2,L+2): while x%i==0: FACT[i]=FACT.get(i,0)+1 x=x//i if x!=1: FACT[x]=FACT.get(x,0)+1 return FACT N,K=map(int,input().split()) A=list(map(int,input().split())) FF=[] for a in A: FF.append(fact(a)) X=set() for ff in FF: X|=set(ff) ANS=1 for x in X: LIST=[] for ff in FF: if x in ff: LIST.append(ff[x]) LIST.sort(reverse=True) ANS=ANS*pow(x,sum(LIST[:K]),mod)%mod print(ANS)