# include using namespace std; typedef long long ll; # define int long long # define lc u << 1 # define rc u << 1 | 1 # define fi first # define se second const int mod = 1e9 + 7; int n, k; map > fac; int quick_pow (int a, int b = mod - 2) { int ans = 1; while (b) { if (b & 1) ans = ans * a % mod; a = a * a % mod; b >>= 1; } return ans; } signed main () { int i,j,k,l,r,x,y; string s; scanf ("%d%d", &n, &k); for (int i = 1; i <= n; i ++ ) { int x; scanf ("%d", &x); map mp; for (int i = 2; i * i <= x; i ++ ) { while (x % i == 0) { mp[i] ++ ; x /= i; } } if (x > 1) mp[x] ++ ; for (auto t : mp) fac[t.fi].push_back (t.se); } int ans = 1; for (auto t : fac) { auto vec = t.se; sort (vec.begin (), vec.end (), greater ()); int sum = 0; for (int i = 0; i <= min (k - 1, (int)vec.size () - 1); i ++ ) sum += vec[i]; ans = ans * quick_pow (t.fi, sum) % mod; } printf ("%d\n", ans); return 0; }