#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define ll long long
#define PB push_back
#define F first
#define S second
#define all(a) a.begin(), a.end()
#define MAX (int)1e6
#define Fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define w(a) cout<<#a<<" : "<<a<<endl;
#define ldb long double
#define vi vector<int>
#define pii pair<int,int>
#define pdi pair<ldb,int>
#define N 1450
#define INF (int)1'450'000

int dp[301][301][301];
const int MOD=(int)1e9+7;

void test1(int n, int k)
{
    int ans=0;
    for(int i=0; i<n; ++i)
    {
        int x; cin>>x; /*x=1e9;*/
        ans=(ans+(1ll*x*(n-i)*(i+1))%MOD)%MOD;
    }
    cout<<ans;
}
void test2(int n, int K)
{
    for(int i=0; i<n; ++i)
    {
        for(int j=i; j<n; ++j)
        {
            dp[i][j][0]=0;
        }
    }
    dp[0][n-1][0]=1;
    for(int k=1; k<=K; ++k)
    {
        for(int j=n-1; j>=0; --j)
        {
            for(int i=0; i<=j; ++i)
            {
                if(i==0 && j==n-1) dp[i][j][k]=1;
                else if(j==n-1) dp[i][j][k]=(dp[i-1][j][k]+dp[i][j][k-1])%MOD;
                else if(i==0) dp[i][j][k]=(dp[i][j+1][k]+dp[i][j][k-1])%MOD;
                else
                {
                    dp[i][j][k]=(1ll*dp[i-1][j][k] + 1ll*dp[i][j+1][k] + 1ll*dp[i][j][k-1] - 1ll*dp[i-1][j+1][k])%(1ll*MOD);
                    if(dp[i][j][k]<0) dp[i][j][k]+=MOD;
                }
            }
        }
    }
    /*for(int i=0; i<n; ++i)
    {
        for(int j=0; j<n; ++j) cout<<dp[i][j][K]<<" "; cout<<endl;
    }*/

    int a[n];
    for(auto &x:a) cin>>x;
    //for(int i=0; i<n; ++i) a[i]=1e9;

    int sume[n][n];
    sume[0][0]=a[0];
    sume[n-1][n-1]=a[n-1];
    for(int i=1; i<n; ++i)
    {
        sume[0][i]=(sume[0][i-1]+a[i])%MOD;
        sume[n-i-1][n-1]=(sume[n-i][n-1]+a[n-i-1])%MOD;
    }
    for(int i=1; i<n-1; ++i)
    {
        for(int j=i; j<n-1; ++j)
        {
            sume[i][j]=(sume[0][n-1]-sume[0][i-1]-sume[j+1][n-1])%MOD;
            if(sume[i][j]<0) sume[i][j]+=MOD;
        }
    }
    int ans=0;
    for(int i=0; i<n; ++i)
    {
        for(int j=i; j<n; ++j)
        {
            ans=(ans+(1ll*sume[i][j]*dp[i][j][K])%MOD)%MOD;
        }
    }
    if(ans<0) ans+=MOD;
    cout<<ans;
}

int main()
{
    Fast;
    int n,K; cin>>n>>K;

    if(n<=1000 && K==1) test1(n,K);
    else test2(n,K);

    return 0;
}