from collections import defaultdict as ddict N, K = map(int, raw_input().split()) a = list(map(int, raw_input().split())) exponents = ddict(list) for ax in a: # primeFactrization cnt = ddict(int) i = 2 while i * i <= ax: while ax % i == 0: cnt[i] += 1 ax /= i i += 1 if ax != 1: cnt[ax] += 1 for key, value in cnt.items(): exponents[key].append(value) mod = 10**9 + 7 ans = 1 for prime, li in exponents.items(): li.sort(reverse = True) num = 0 for i in range(min(K, len(li))): num += li[i] ans *= pow(prime, num, mod) ans %= mod print ans