#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ull = unsigned long long; ull fast_pow(ull num,ull n) { ull x = num; ull result = 1; while(n) { if(n & 1) result *= x; x *= x; n = n >> 1; } return result; } int main() { ull n,k; cin >> n >> k; vector a(n); map> dic; for(int i =0; i < n; ++i) { cin >> a.at(i); ull tmp = a.at(i); int j = 2; while(j <= static_cast(sqrt(a.at(i)))) { if(tmp % j ==0) { vector t(n,0); tmp /= j; if(dic.find(j) != dic.end()) { dic.at(j).at(i) +=1; } else { dic.emplace(j,t); dic.at(j).at(i) = 1; } } else { ++j; } } vector t(n,0); if(dic.find(tmp) != dic.end()) { dic.at(tmp).at(i) +=1; } else { dic.emplace(tmp,t); dic.at(tmp).at(i) = 1; } } ull sum = 1; for(auto&& x : dic) { sort(x.second.begin(),x.second.end(),greater()); ull count = 0; for(int i =0; i < k ; ++i) { count += x.second.at(i); } sum = (sum*fast_pow(x.first,count)) % static_cast(1e9+7); } cout << sum << endl; }