#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;
ll N,K,niz[200005],prefiks[200005],koliko[200005],pamti[305][305][305];
ll uradi(int k,int l,int r){
    ll ret=0;
    //pamti[k][l][r]++;
    if(pamti[k][l][r]!=-1)
        return pamti[k][l][r];
   // cout<<"uradi("<<k<<","<<l<<","<<r<<")"<<endl;
    if(k==0){
        for(int i=l;i<=r;i++)
            koliko[i]++;
        pamti[k][l][r]=prefiks[r]-prefiks[l-1];
        return prefiks[r]-prefiks[l-1];
    }
    for(int i=l;i<=r;i++)
        for(int j=i;j<=r;j++)
            ret=(ret+uradi(k-1,i,j))%MOD;

    pamti[k][l][r]=ret;
    return ret;
}
int main(){
    ios_base::sync_with_stdio(false);
    memset(pamti,0,sizeof(pamti));
    cin>>N>>K;
    for(int i=1;i<=N;i++){
        cin>>niz[i];
        prefiks[i]=(prefiks[i-1]+niz[i])%MOD;
    }
    if(K==1){
        ll res=0;
        for(int i=1;i<=N;i++)
            res=(res+(((i)*(N-i+1))%MOD)*niz[i])%MOD;
        cout<<res<<endl;
        return 0;
    }
    cout<<uradi(K,1,N)<<endl;
    return 0;