#include <iostream>
#include <vector>

using namespace::std;

long long mod = 1000000007;

long long funk(vector<int>v, int k) {
	if (k == 0) {
		long long sum = 0;
		for (auto i : v) {
			sum = (sum + i) % mod;
		}
		return sum;
	}
	else {
		long long sum = 0;
		for (int i = 0; i < v.size(); i++) {
			vector<int> pom;
			for (int j = i; j < v.size(); j++) {
				pom.push_back(v[j]);
				sum += funk(pom, k - 1);
			}
		}
		return sum;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin >> n >> k;
	vector<int> g;
	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		g.push_back(a);
	}
	if (k == 1) {
		int len = g.size();
		int dlen = len;
		long long sum = 0;
		if (len % 2 != 0) {
			for (int i = 0; i < len / 2; i++) {
				sum = (sum + (g[i] + g[len - 1 - i]) * dlen) % mod;
				dlen += (len - 2*(i+1));
			}
			sum = (sum + (g[len/2]) * dlen) % mod;
		}
		else {
			for (int i = 0; i < len / 2; i++) {
				sum = (sum + (g[i] + g[len - 1 - i]) * dlen) % mod;
				dlen += (len - 2 * (i + 1));
			}
		}
		cout << sum;
	}
	else if (k <= 5 && n <= 5) {
		cout << funk(g, k);
	}
	return 0;
}