import java.io.*; import java.util.*; import java.util.Map.*; public class Main_yukicoder368 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); Prime p = new Prime(100_000); List primes = p.getPrimeList(100_000); int n = sc.nextInt(); int k = sc.nextInt(); Map> hm = new HashMap<>(); for (int i = 0; i < n; i++) { int a = sc.nextInt(); int tmp = a; for (int j : primes) { if (j * j > a) { break; } int cnt = 0; while (tmp % j == 0) { cnt++; tmp /= j; } if (hm.containsKey(j)) { hm.get(j).add(cnt); } else { List ltmp = new ArrayList<>(); ltmp.add(cnt); hm.put(j, ltmp); } } if (tmp != 1) { if (hm.containsKey(tmp)) { hm.get(tmp).add(1); } else { List ltmp = new ArrayList<>(); ltmp.add(1); hm.put(tmp, ltmp); } } } final long MOD = 1_000_000_007; long ret = 1; for (Entry> e : hm.entrySet()) { List bp = e.getValue(); Collections.sort(bp); int pp = 0; for (int i = bp.size() - 1; bp.size() - i <= k && i >= 0; i--) { pp += bp.get(i); } ret = ret * pow(e.getKey(), pp, MOD) % MOD; } pr.println(ret); pr.close(); sc.close(); } private static long pow(int a, int n, long MOD) { int loop = n; long ret = 1; long x = a; while (loop > 0) { if (loop % 2 == 1) { ret = ret * x % MOD; } x = x * x % MOD; loop /= 2; } return ret; } @SuppressWarnings("unused") private static class Prime { private int n; private List primes; private BitSet p; Prime(int n) { this.n = n; p = new BitSet(n / 2); int m = (int)Math.sqrt(n); for (int i = 1; i <= m; i++) { if (p.get(i - 1)) { continue; } for (int j = 2 * i * (i + 1); 2 * j + 1 <= n; j += 2 * i + 1) { p.set(j - 1); } } } boolean isPrime(int n) { if (n == 2) { return true; } if (n == 1 || (n & 0x1) == 0) { return false; } return !p.get(n / 2 - 1); } List getPrimeList(int n) { if (primes != null) { return primes; } primes = new ArrayList<>(); primes.add(2); for (int i = 1; 2 * i + 1 <= n; i++) { if (!p.get(i - 1)) { primes.add(2 * i + 1); } } return primes; } private static boolean isPrime(long n) { if (n == 2) { return true; } if (n == 1 || (n & 0x1) == 0) { return false; } for (long i = 3; i * i <= n; i += 2) { if (n % i == 0) { return false; } } return true; } } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { it = Arrays.asList(br.readLine().split(" ")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }