#include #include #include using namespace std; #define RREP(i,s,e) for (i = s; i >= e; i--) #define rrep(i,n) RREP(i,n-1,0) #define REP(i,s,e) for (i = s; i < e; i++) #define rep(i,n) REP(i,0,n) #define INF 100000000 #define MOD 1000000007 typedef long long ll; ll gcd(int a, int b) { return b == 0 ? a : gcd(b,a%b); } ll power(ll x, int n) { ll ret = 1; while (n > 0) { if (n % 2) { ret *= x; ret %= MOD; } x *= x; x %= MOD; n /= 2; } return ret; } ll lcm(ll a, ll b) { return a * b % MOD * power(gcd(a,b),MOD-2) % MOD; } int main() { int i, n, k, d; ll ans; int a[1000]; cin >> n >> k; rep (i,n) cin >> a[i]; if (k == 1) { ans = 1; rep (i,n) ans = lcm(ans,a[i]); } else { ans = a[0]; REP (i,1,n) ans = (ans * a[i]) % MOD; d = 1; rep (i,n) d = gcd(d,a[i]); ans = (ans * power(d,MOD-2)) % MOD; } cout << ans << endl; return 0; }