N,K = map(int,input().split()) P = 10 ** 9 + 7 ans = 1 a = list(map(int,input().split())) C = 4 * 10 ** 4 dat = [0] * C for i in range(2,C): if dat[i] == 0: for j in range(2 * i,C,i): dat[j] = 1 l = [] for j in range(N): count = 0 while a[j] % i == 0: count += 1 a[j] //= i if count: l.append(count) l.sort(reverse = True) _sum = 0 for j in l[:K]: _sum += j ans = ans * pow(i,_sum,P) % P from collections import defaultdict d = defaultdict(int) for i in a: if i > 1: d[i] += 1 for i in d: if d[i] > K: ans = ans * pow(i,K,P) % P else: ans = ans * pow(i,d[i],P) % P print(ans)