import java.util.*; public class Main { static final int MOD = 1000000007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); HashMap> result = new HashMap<>(); for (int i = 0; i < n; i++) { int x = sc.nextInt(); for (int j = 2; j <= Math.sqrt(x); j++) { int count = 0; while (x % j == 0) { count++; x /= j; } if (count > 0) { if (!result.containsKey(j)) { result.put(j, new ArrayList<>()); } result.get(j).add(count); } } if (x > 1) { if (!result.containsKey(x)) { result.put(x, new ArrayList<>()); } result.get(x).add(1); } } long ans = 1; for (int x : result.keySet()) { Collections.sort(result.get(x)); for (int i = 0; i < result.get(x).size() && i < k; i++) { for (int j = 0; j < result.get(x).get(result.get(x).size() - i - 1); j++) { ans *= x; ans %= MOD; } } } System.out.println(ans); } }