#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define INF 1000000000
#define LINF 1000000000000000LL
#define pb push_back
#define all(x) x.begin(), x.end()
#define len(s) (int)s.size()
#define test_case { int t; cin>>t; while(t--)solve(); }
#define single_case solve();
#define line cerr<<"----------"<<endl;
#define ios { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL); }
#define mod 1000000007LL
const int N = 303;
ll dp[N][N][N];
ll prefix[N][N];
int n, kk;
ll a[N];



int main()
{
    ios
    cin>>n>>kk;
    ll ans;
    for(int i = 1;i<=n;i++)
        cin>>a[i];
    for(int j = 1;j<=n;j++)
    {
        for(int i = 1;i<=j;i++)
        {
            prefix[i][j] = (prefix[i-1][j] + a[i]) % mod;
        }
    }
    for(int j = 1;j<=n;j++)
    {
        for(int i = 1;i<=n;i++)
        {
            for(int k = i;k<=j;k++) dp[i][j][0] += (prefix[k][j] - prefix[i-1][j]) % mod;
        }
    }
    for(int j = 1;j<=n;j++)
    {
        for(int i = 1;i<=j;i++)
        {
            prefix[i][j] = (prefix[i-1][j] + dp[i][j][0]) % mod;
        }
    }
    ans = 0;
    for(int i = 1;i<=n;i++) ans += a[i], ans%=mod;
    for(int k = 1;k<=kk;k++)
    {
        /*for(int j = 1;j<=n;j++)
        {
            for(int i = 1;i<=j;i++)
                cout<<prefix[i][j]<<" ";
            cout<<endl;
        }*/
        for(int i = 1;i<=n;i++)
        {
            for(int j = i;j<=n;j++)
            {
                //for(int l = i;l<=j;l++) dp[i][j][k] += dp[l][j][k-1];
                dp[i][j][k] = prefix[j][j] - prefix[i-1][j];
                if(dp[i][j][k]<0) dp[i][j][k] += mod;
                else if(dp[i][j][k]>=mod) dp[i][j][k] %= mod;
            }
        }
        ans = dp[1][n][k];
        for(int j = 1;j<=n;j++)
        {
            for(int i = 1;i<=j;i++)
            {
                prefix[i][j] = (prefix[i-1][j] + dp[i][j][k]) % mod;
            }
        }
        for(int j = 1;j<=n;j++)
        {
            for(int i = 1;i<=j;i++)
            {
                dp[i][j][k] = 0;
            }
        }
        for(int j = 1;j<=n;j++)
    {
        for(int i = 1;i<=n;i++)
        {
            for(int w = i;w<=j;w++) dp[i][j][k] += (prefix[w][j] - prefix[i-1][j]) % mod;
        }
    }
    for(int j = 1;j<=n;j++)
    {
        for(int i = 1;i<=j;i++)
        {
            prefix[i][j] = (prefix[i-1][j] + dp[i][j][k]) % mod;
        }
    }
    }
    /*for(int j = 1;j<=n;j++)
        {
            for(int i = 1;i<=j;i++)
                cout<<prefix[i][j]<<" ";
            cout<<endl;
        }*/

    cout<<ans;





    return 0;
}