import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int M = (int)Math.pow(10, 4); ArrayList prime = new ArrayList(); boolean[] is_prime = new boolean[M + 1]; for(int i = 0; i <= M; i++) is_prime[i] = true; is_prime[0] = false; is_prime[1] = false; for(int i = 2; i <= M; i++) { if(is_prime[i]) { prime.add(i); for(int j = 2 * i; j <= n; j += i) is_prime[j] = false; } } int t = prime.size(); int[][] rui = new int[n][t]; for(int i = 0; i < n; i++) { int a = sc.nextInt(); for(int j = 0; j < t; j++) { int p = prime.get(j); while(a % p == 0) { a /= p; rui[i][j]++; } } } long ans = 1; long MOD = (long)Math.pow(10, 9) + 7; for(int j = 0; j < t; j++) { int[] r = new int[n]; for(int i = 0; i < n; i++) { r[i] = rui[i][j]; } Arrays.sort(r); int p = prime.get(j); for(int l = n - 1; l >= n - k; l--) { ans = (ans * (long)Math.pow(p, r[l])) % MOD; } } System.out.println(ans); } }