#include #include #include #include #include #include #include #include #include #include #include #include #include #define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++) #define rep(i,n) repd(i,0,n) #define all(x) (x).begin(),(x).end() #define mod 1000000007 #define inf 2000000007 #define mp make_pair #define pb push_back typedef long long ll; using namespace std; template inline void output(T a, int p) { if(p) cout << fixed << setprecision(p) << a << "\n"; else cout << a << "\n"; } // end of template ll gcd(ll a, ll b) { if(b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return (a / gcd(a, b) * b) % mod; } int main() { cin.tie(0); ios::sync_with_stdio(0); // source code int N, K; cin >> N >> K; vector A(N); rep(i, N) cin >> A[i]; ll ret = 1; rep(i, K) { ret *= A[i]; ret %= mod; } // cout << ret << endl; repd(i, K, N) { ll l = 1; rep(j, i) { ll g = gcd(A[i], A[j]); // cout << "g: " << g << endl; l = lcm(l, A[i] / g); // cout << "l: " << l << endl; } (ret *= l) %= mod; // cout << ret << endl; } output(ret, 0); return 0; }