from heapq import heappop, heappush from collections import defaultdict n, k = map(int, input().split()) A = list(map(int, input().split())) mod = 10**9 + 7 P = defaultdict(list) C = defaultdict(int) for i in range(n): a = A[i] f = 2 while f * f <= a: cnt = 0 while a % f == 0: cnt += 1 a //= f if cnt > 0: if len(P[f]) < k: heappush(P[f], cnt) C[f] += cnt else: d = heappop(P[f]) C[f] -= d res = max(d, cnt) heappush(P[f], res) C[f] += res f += 1 if a != 1: if len(P[a]) < k: heappush(P[a], 1) C[a] += 1 else: d = heappop(P[a]) C[a] -= d res = max(d, 1) heappush(P[a], res) C[a] += res ans = 1 for val, cnt in C.items(): ans *= pow(val, cnt, mod) ans %= mod print(ans)