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> allMap = new HashMap<>(); for (int i = 0; i < n; i++) { HashMap map = new HashMap<>(); int x = sc.nextInt(); for (int j = 2; j <= Math.sqrt(x); j++) { while (x % j == 0) { if (map.containsKey(j)) { map.put(j, map.get(j) + 1); } else { map.put(j, 1); } x /= j; } } if (x != 1) { if (map.containsKey(x)) { map.put(x, map.get(x) + 1); } else { map.put(x, 1); } } for (Map.Entry entry : map.entrySet()) { if (!allMap.containsKey(entry.getKey())) { allMap.put(entry.getKey(), new ArrayList()); } allMap.get(entry.getKey()).add(entry.getValue()); } } long total = 1; for (Map.Entry> entry : allMap.entrySet()) { ArrayList list = entry.getValue(); Collections.sort(list); int sum = 0; for (int i = 0; i < list.size() && i < k; i++) { sum += list.get(list.size() - i - 1); } total *= pow(entry.getKey(), sum); total %= MOD; } System.out.println(total); } static long pow(int base, int power) { long ans = 1; for (int i = 0; i < power; i++) { ans *= base; ans %= MOD; } return ans; } }