#include <bits/stdc++.h>

#define pb push_back
#define ll long long
#define pii pair<int, int>
#define xx first
#define yy second
#define MOD 1000000007

using namespace std;

ll dp[310][310][310], n, k, a[310], p[310], ress;

ll add (ll x, ll y)
{
    ll ress=x+y;
    if (ress>=MOD) ress-=MOD;
    return ress;
}
ll mul (ll x, ll y)
{
    ll ress=x*y;
    if (ress>=MOD) ress%=MOD;
    return ress;
}
ll sub (ll x, ll y)
{
    ll ress=x-y;
    if (ress<0) ress+=MOD;
    return ress;
}

ll uradi(int i, int j, int k)
{
    if (dp[i][j][k]) return dp[i][j][k];

    if (k==0) { return dp[i][j][k]=p[j]-(i==0 ? 0 : p[i-1]); }

    for (int x=i; x<=j; x++)
    {
        for (int y=x; y<=j; y++) dp[i][j][k]=add(dp[i][j][k], uradi(x, y, k-1));
    }
    return dp[i][j][k];
}

ll uradi2(int i, int j, int k)
{
    //cout<<i<<" "<<j<<" "<<k<<endl;
    if (dp[i][j][k]) return dp[i][j][k];

    if (k==0) { if (i==0 && j==n-1) return dp[i][j][k]=1; else return dp[i][j][k]=0; }

    ll ress=0;
    if (i) ress=add(ress, uradi2(i-1, j, k));
    if (j<n-1) ress=add(ress, uradi2(i, j+1, k));
    if (i && j<n-1) ress=sub(ress, uradi2(i-1, j+1, k));
    ress=add(ress, uradi2(i, j, k-1));

    dp[i][j][k]=ress;
    return dp[i][j][k];
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    srand(time(NULL));

    cin>>n>>k;
    //n=rand()%75;
    //k=rand()%75;
    for (int i=0; i<n; i++)  cin>>a[i]; //a[i]=rand()%1000000001;

    //cout<<n<<" "<<k<<endl;
    if (k==1)
    {
        ll ress=0;
        for (int i=0; i<n; i++)
        {
            ress=add(ress, mul(mul(i+1, n-i), a[i]));
        }
        cout<<ress;
        exit(0);
    }

    p[0]=a[0];
    for (int i=1; i<n; i++) p[i]=p[i-1]+a[i];

    //auto start = std::chrono::steady_clock::now();
    //std::cout << "f(42) = " << fibonacci(42) << '\n';

    //cout<<uradi(0, n-1, k)<<endl;
    //cout<<"ee"<<endl;

    for (int i=0; i<n; i++)
        for (int j=i; j<n; j++)
            uradi2(i, j, k);

    for (int i=0; i<n; i++)
    {
        for (int j=i; j<n; j++)
        {
            //cout<<i+1<<" "<<j+1<<" "<<dp[i][j][k]<<endl;
            ll segsum=p[j] - (i==0 ? 0 : p[i-1]);
            ress=add(ress, mul(dp[i][j][k], segsum));
        }
    }

    cout<<ress<<endl;
//    auto end = std::chrono::steady_clock::now();
//    std::chrono::duration<double> elapsed_seconds = end-start;
//    std::cout << "elapsed time: " << elapsed_seconds.count() << "s\n";
}