#include <bits/stdc++.h>

using namespace std;

#define ll long long

// ako je k = 0 zbir je suma svih elemenata
// za k > 0 zbir je suma svih suma od i do n f(T[i...j], k-1) za k > 0
// ako je k = 1
ll m = 1000000007;

ll Sum(ll T[], ll p, ll n)
{
	ll ret = 0;
	for (ll i = p; i <= n; i++)
	{
		ret = (ret + T[i]) % m;
	}
	return ret;
}

ll F(ll T[], ll p, ll n, ll k)
{
	if (k == 0)
	{
		return Sum(T, p, n);
	}
	if (k == 1)
	{
		ll suma = 0;
		for (ll i = 0; i <= n; i++)
		{
			// LETS GO
			ll s = (T[i] * (i+1) * (n-i+1)) % m;
			suma += s;
		}
		return suma;
	}
	else
	{
		ll suma = 0;
		for (ll i = 0; i <= n; i++)
		{
			ll s = F(T, i, n, k-1);
			suma += s;
		}
		return suma;
		
	}
	return 0;
}	

int main()
{
	ll n, k;
	cin >> n;
	cin >> k;
	ll niz[n];
	for (ll i = 0; i < n; i++)
	{
		ll x;
		cin >> x;
		niz[i] = x;
	}
	cout << F(niz, 0, n-1, k);
	return 0;
}