#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
#define int long long
const int N = 2e5 + 5, p = 1e9 + 7;
pair<int, int> nums[N], heap[N];
int ans, arr[N], dLog[N];
long double Logarr[N];
signed main()
{
int n, k; cin >> n >> k;
for (int i = 1; i <= n; i++)
{
cin >> arr[i];
}
sort(arr + 1, arr + n + 1);
for (int i = 1; i <= n; i++)
{
Logarr[i] = log2(arr[i]);
}
//dLog[i]表示把前i个数的log2值都变成
//log2(arr[i])所需要的操作次数
for (int i = 1; i <= n; i++)
{
for (int j = 1; j < i; j++)
{
dLog[i] += floor(Logarr[i] - Logarr[j]);
}
}
int stop = n, times = 0;
for (int i = 1; i <= n; i++)
{
if (k < dLog[i])
{
stop = i - 1; break;
}
}
times = k - dLog[stop];
//先把前stop - 1个数都不断乘而直至它们的log2值都等于log2(arr[stop])
//再把剩下的操作次数(times)***队前优先平均***分给前stop个数
//由于可以使用快速幂,所以会比小根堆的实现更快
for (int i = 1; i < stop; i++)
{
arr[i] = power(arr[i], floor(Logarr[stop] - Logarr[i]));
}
int t = times / stop, s = times - t * stop;
for (int i = 1; i <= stop; i++)
{
if (i <= s) arr[i] = power(arr[i], t + 1);
else arr[i] = power(arr[i], t);
}
for (int i = 1; i <= n; i++)
{
ans += arr[i]; ans %= p;
}
cout << ans;
return 0;
}