#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 dp1[N][N][N];
ll prefix[N][N];
int n, kk;
ll a[N];



int main()
{
    ios
    cin>>n>>kk;
    ll ans;
    ans = 0;
    for(int i = 1;i<=n;i++)
        cin>>a[i];
    for(int i = 1;i<=n;i++)
        ans += a[i];
    for(int j = 1;j<=n;j++)
    {
        for(int i = 1;i<=j;i++)
        {
            for(int k = i;k<=j;k++)
            {
                dp1[i][j][0] += a[k];
                dp1[i][j][0] %= mod;
            }
        }
    }
    for(int i = 1;i<=n;i++)
    {
        for(int j = i;j<=n;j++)
        {
            for(int k = i;k<=j;k++)
            {
                dp[i][j][0] += dp1[i][k][0];
                dp[i][j][0] %= 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;
        }
    }
    for(int k = 1;k<=kk;k++){
    for(int i = 1;i<=n;i++)
    {
        for(int j = i;j<=n;j++)
        {
            dp1[i][j][k] = prefix[j][j] - prefix[i-1][j];
            if(dp1[i][j][k]<0) dp[i][j][k] += mod;
        }
    }
    ans = dp1[1][n][k];
    for(int i = 1;i<=n;i++)
    {
        for(int j = i-1;j<=n;j++)
        {
            prefix[i][j] = 0;
        }
    }
    for(int i = 1;i<=n;i++)
    {
        for(int j = i;j<=n;j++)
        {
            prefix[i][j] = (prefix[i][j-1] + dp1[i][j][k]) % mod;
        }
    }
    for(int i = 1;i<=n;i++)
    {
        for(int j = i;j<=n;j++)
        {
            dp[i][j][k] = prefix[i][j] - prefix[i][i-1];
            if(dp[i][j][k]<0) dp[i][j][k] += 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;
         }
     }
}

    cout<<ans;

    return 0;
}