///sat
#include <chrono>
using namespace std::chrono;
#define vremestart auto start = high_resolution_clock::now();
#define vremeend auto stop = high_resolution_clock::now();
#define vremeispis auto duration = duration_cast<microseconds>(stop - start); cout << duration.count() << endl;
///sat
#define here cerr<<"here\n";
#define popcount(x) __builtin_popcount(x) ///broji broj bitova
#include <bits/stdc++.h>
#define mode 998244353
#define mod 1000000007
#define gcd __gcd
#define ld long double
#define ll unsigned long long
#define ull unsigned long long
#define llinf 1000000000000000000LL
#define iinf 2000000000
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define th third
#define fo fourth
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define rall(a) a.begin(),a.end(),greater<int>()
using namespace std;
#define maxn 100005
ll a[maxn];
ll p[maxn];
ll b[maxn];
//long long c[maxn];
ll n,k;
ll solve(int i,int j,int k){
    //cerr<<i<< " "<<j<<" "<<k<<"\naaaaa";
    if(k==0){
        ll sum = p[j]-p[i-1];
        //c[i]++;
        //c[j+1]--;
        if(sum>=mod) sum%=mod;
        return sum;
    }
    ll sum = 0;
    for(int w = i;w<=j;w++){
        for(int g = w;g<=j;g++){
            //cerr<<w<< " " <<g<<" "<<k-1<<"\n";
            sum+=solve(w,g,k-1);
            if(sum>=mod) sum%=mod;
        }
    }
    return sum;
}
ll binomialCoeff(ll n, ll k)
{
    ll res = 1;
    if (k > n - k)
        k = n - k;
    for (ll i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
int main(){
	ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
    cin >> n >> k;
    for(int i = 1;i<=n;i++){
        cin >> a[i];
        p[i] = p[i-1]+a[i];
        if(p[i]>=mod) p[i]%=mod;
    }
    if(k==0){
        ll ans = 0;
        for(int i = 1;i<=n;i++){
            ans+=a[i];
            if(ans>=mod) ans%=mod;
        }
        cout<<ans;
        return 0;
    }
    if(k==1){
        ll ans = 0;
        for(int i = 1;i<=n;i++){
            for(int j = i;j<=n;j++){
                ans+=p[j]-p[i-1];
                if(ans>=mod) ans%=mod;
            }
        }
        cout<<ans;
        return 0;
    }
    if(n<=5&&k<=5){
        ll ans = solve(1,n,k);
        cout<<ans;
        /*for(int i = 1;i<=n;i++) c[i]+=c[i-1];
        ans = 0;
        /*for(int i = 1;i<=n;i++) cerr<<c[i]<< " ";
        cerr<<"\n";*/
        return 0;
    }
    ll ans = 0;
    ans+=binomialCoeff(n-1+k,n-1)*(a[1]+a[n]);
    for(ll i = 2;2*i<=n;i++){
        ll g = binomialCoeff(k+n-i,n-i)*binomialCoeff(k+i-1,i-1);
        if(g>=mod) g%=mod;
        g*=(a[i]+a[n-i+1]);
        //cerr<<i<< " "<<n-i+1<<"\n";
        if(g>=mod) g%=mod;
        ans+=g;
        if(ans>=mod) ans%=mod;
    }
    if(n%2==1){
        ll i = n/2+1;
        ll g = binomialCoeff(k+n-i,n-i)*binomialCoeff(k+i-1,i-1);
        if(g>=mod) g%=mod;
        ans+=a[i]*g;
        if(ans>=mod)ans%=mod;
    }
    cout<<ans;
    return 0;
}
/*
5 5
1 2 3 4 5
output: 4095
5 4
1 2 3 4 5
output: 2145
5 3
1 2 3 4 5
output: 990
*/
/*
10 6
1 3 5 78 3 5 1 5 983 34
output: 28290185
*/