#include using namespace std; typedef long long ll; typedef vector< int > vi; typedef vector< vi > vvi; typedef vector< ll > vl; typedef vector< vl > vvl; typedef pair< int, int > pii; typedef vector< pii > vp; typedef vector< double > vd; typedef vector< vd > vvd; typedef vector< string > vs; template< class T1, class T2 > int upmin( T1 &x, T2 v ){ if( x > v ){ x = v; return 1; } return 0; } template< class T1, class T2 > int upmax( T1 &x, T2 v ){ if( x < v ){ x = v; return 1; } return 0; } const int INF = 0x3f3f3f3f; const int MOD7 = ( int ) 1e9 + 7; int N, K; vi A; void init(){ cin >> N >> K; A = vi( N ); for( int i = 0; i < N; ++i ){ cin >> A[ i ]; } } map< int, priority_queue< int > > prime2pq; void preprocess(){ for( int i = 0; i < N; ++i ){ for( int j = 2; j * j <= A[ i ]; ++j ){ int v = 1; while( A[ i ] % j == 0 ){ v = 1LL * v * j % MOD7; A[ i ] /= j; } if( v > 1 ){ prime2pq[ j ].emplace( v ); } } if( A[ i ] != 1 ){ prime2pq[ A[ i ] ].emplace( A[ i ] ); } } } void solve(){ int ans = 1; for( auto it = prime2pq.begin(); it != prime2pq.end(); ++it ){ for( int i = 0; i < K; ++i ){ if( it->second.empty() ){ break; } ans = 1LL * ans * it->second.top() % MOD7; it->second.pop(); } } cout << ans << endl; } signed main(){ ios::sync_with_stdio( 0 ); init(); preprocess(); solve(); return 0; }