#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin >>n>>k;
    vector <long long> a(n);

    vector <vector <long long> >DP(k+1,vector <long long> (n+1) );
    for(int i=0;i<=n;i++)DP[0][i]=1;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=n;j++){
            DP[i][j]=DP[i-1][j]+DP[i][j-1];
            DP[i][j]%=mod;
        }
    }/*
    for(int i=0;i<=k;i++){
        for(int j=0;j<=n;j++){
            cout <<DP[i][j]<<" ";
        }
        cout <<endl;
    }
    cout <<endl;*/
    for(int i=0;i<n;i++)cin >>a[i];
    long long rez=0;
    for(int i=0;i<n;i++){
            long long curr=DP[k][i+1]*DP[k][n-i];
            curr%=mod;
            curr*=a[i];
            curr%=mod;
            rez+=curr;
            rez%=mod;
    }
cout <<rez<<endl;
}