#include <iostream>

using namespace std;

long int f(long int niz[1000], long int k, long int duzina) 
{
	long int pom[1000];
	unsigned long long int res = 0;
	
	if (k > 1) 
	{
		for (long int i = 0; i < duzina; i++) 
		{
			long int tren[1000];
			for (long int j = i; j <= duzina; j++)
			{
				tren[j - i] = niz[j];
				/*for (int m = 0; m <= j - i; m++) 
				{
					cout << i << " -> " << tren[m] << " "<< endl;
				}
				cout << endl;*/
				res += f(tren, k - 1, j - i);
			}
		}
	}
	else 
	if (k == 1)
	{
		long int poc = 0;
		for (long int i = 0; i < duzina; i++) 
		{
			pom[i] = poc + duzina - i - i;
			//cout << i << " -> " << pom[i] << " "<< endl;
			res += pom[i] * niz[i];
			poc = pom[i];
		}
	}
	else 
	{
		for (long int i = 0; i < duzina; i++) 
		{
			//cout << "tren" << " -> " << niz[i] << " "<< endl;
			res += niz[i];
		}
		//cout << "Res: " << res << endl << endl;
	}
	return res;
}

int main () 
{
	long int N, k, niz[1000];
	
	cin >> N >> k;
	
	for (long int i = 0; i < N; i++) 
	{
		cin >> niz[i];
	}
	
	unsigned long long int resenje = f(niz, k, N);
	while (resenje >= 1000000007) resenje -= 1000000007;
	cout << f(niz, k, N);
	return 0;	
}