#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
#define fi first
#define se second

using namespace std;
typedef long long ll;

ll m=1000000007;
ll maxk=200050;

st(ll a, ll b)
{
    a%=m;
    ll res=1;
    while(b>0)
    {
        if(b&1)
        {
            res=(res*a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

ll inv(ll a)
{
    return st(a, m-2);
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, k;
	cin >> n >> k;
	vector<ll> v(n);
	vector<ll> a(n);
	vector<ll> A(n);
	a[0]=n;
	cin >> v[0];
	for(ll i=1; i<n; i++)
    {
        cin >> v[i];
        a[i]=(a[i-1]-2*i+n)%m;
    }
	if(k==0)
    {
        for(ll i=0; i<n; i++)
        {
            a[i]=1;
        }
    }
    ll r=0;
    for(ll i=0; i<n; i++)
    {
        ll tr=a[i];
        ll res=tr;
        for(ll j=2; j<=k; j++)
        {
            tr=((tr+n)%m+(j-1)*2)%m;
            res=(((res*tr)%m*inv(j))%m*inv(j))%m;
        }
        r=(r+(res*v[i])%m)%m;
    }
    cout << r << "\n";
}