#include <iostream>
#include <vector>
#define print(x) cout << #x << " = " << x << endl;
#define MOD 1000000007
//#define printVec(x) cout << "{ "; for (int q = 0; q < x.size()-1; q++) cout << x[q] << ", "; cout << x.back() << " }\n";

using namespace std;

long long sum = 0;

int n, k;
int a[200005];

void bf(vector<int> arr, int k)
{
	if (k == 0)
	{
		for (int i = 0; i < arr.size(); i++)
		{
			sum += arr[i];
		}
		return;
	}
	for (int i = 0; i < arr.size(); i++)
	{
		for (int j = i; j < arr.size(); j++)
		{
			vector<int> x = vector<int>(arr.begin() + i, arr.begin() + j + 1);
			if (x.size() == 1) bf(x, 0);
			else bf(x, k - 1);
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(); cout.tie();
	cin >> n >> k;
	double avg = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		avg += a[i];
	}

	avg /= n;

	if (k == 1)
	{
		double total = (double)n * ((long long)n + 1) * ((long long)n + 2) / 6;
		sum = (long long)(total * avg);
		sum %= MOD;
		cout << sum << endl;
	}
	else if (k == 0)
	{
		cout << (long long)(avg * n) << endl;
	}
	else
	{
		bf(vector<int>(a, a + n), k);
		cout << sum << endl;
	}
}