require 'prime' N, K = gets.split.map(&:to_i) A = gets.split.map(&:to_i) MOD = 10 ** 9 + 7 counter = Hash.new { |h, k| h[k] = [] } A.each do |a| a.prime_division.each do |e, cnt| counter[e] << cnt end end ans = 1 counter.each do |e, nums| cnt = nums.sort.reverse.take(K).sum ans *= e.pow(cnt, MOD) ans %= MOD end puts ans