#include using namespace std; using ll=int64_t; #define REP(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define RER(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) template void input(T &x, size_t n) { for(int i = 0; i < n; i++) { cin >> x[i]; } } //=====debug====== void* enabler; #define debug(...) cout << __VA_ARGS__ << endl; template class has_begin_and_end { private: template static auto check( U v ) -> decltype( v.begin(), v.end(), std::true_type() ); static auto check( ... ) -> decltype( std::false_type() ); public: typedef decltype( check( std::declval() ) ) type; static bool const value = type::value; }; template class has_top_and_pop { private: template static auto check( U v ) -> decltype( v.empty(), v.top(), v.pop(), std::true_type() ); static auto check( ... ) -> decltype( std::false_type() ); public: typedef decltype( check( std::declval() ) ) type; static bool const value = type::value; }; template class has_front_and_pop { private: template static auto check( U v ) -> decltype( v.empty(), v.front(), v.pop(), std::true_type() ); static auto check( ... ) -> decltype( std::false_type() ); public: typedef decltype( check( std::declval() ) ) type; static bool const value = type::value; }; template::value>::type*& = enabler> void output(const T& val){ auto it = val.begin(); cout << (*it++); for(; it != val.end(); ++it) cout << ' ' << (*it); cout << endl; } template::value>::type*& = enabler> void output(T val){ while(!val.empty()){ debug(val.top()); val.pop(); } } template::value>::type*& = enabler> void output(T val){ while(!val.empty()){ debug(val.front()); val.pop(); } } template ostream& operator<<(ostream& os, const pair& v) { os << "(" << v.first << ", " << v.second << ")"; return os; } const int MAX = 1e9; const int MOD = 1e9+7; vector prime; void make() { vector used(MAX); used[0] = used[1] = true; for(int i = 2; i*i < MAX; i++) { if(used[i]) continue; prime.emplace_back(i); for(int j = i+i; j < 1e7; j += i) { used[j] = true; } } } int main() { make(); int n, k; ll res = 1LL; cin >> n >> k; vector a(n); input(a, n); vector x[100000]; REP(i, n) { int k = a[i]; REP(j, prime.size()) { int count = 0; if(k == 1) break; while(k%prime[j]==0) { k/=prime[j]; count++; } if(prime.size() - 1 == j) { if(k > 1) { prime.emplace_back(k); } } if(count == 0) continue; x[j].emplace_back(count); } } REP(i, prime.size()){ sort(x[i].begin(), x[i].end(), greater()); int l = min(k, (int)(x[i].size())); REP(j, l) { REP(k, x[i][j]) { res *= prime[i]; res %= MOD; } // cout << prime[i] << ' ' << x[i][j] << endl; //res *= ((ll)pow(prime[i], x[i][j]) % MOD); } } cout << res << endl; }