#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define sz(a) a.size()
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
const int inf = 2e9;
const ll linf = 4e18;
vector<ll> a;
int dp[310][310][310];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
    ll n, kk;
    cin >> n >> kk;
    a.resize(n);
    ll s = 0;
    for (ll i = 0; i < n; i++)cin >> a[i];
    if (kk == 0) {
        for (ll i = 0; i < n; i++)s += a[i];
        cout << s % mod;
        return 0;
    }
    if (kk == 1) {
        for (ll i = 0; i < n; i++) {
            s += (a[i] * ((i + 1) * (n - i) % mod) % mod); s %= mod;
        }
        cout << s;
        return 0;
    }
    for(int i=0;i<n;i++){
        dp[0][i][i]=a[i];
        for(int j=i+1;j<n;j++){
            dp[0][i][j]=dp[0][i][j-1]+a[j];
        }
    }
    for(int k=1;k<=kk;k++){
        for (int l=0;l<n;l++){
            for (int r=l;r<n;r++){
                for (int i=l;i<=r;i++){
                    for(int j=i;j<=r;j++){
                        dp[k][l][r]+=dp[k-1][i][j];
                        if(dp[k][l][r]>=mod)dp[k][l][r]%=mod;
                    }
                }
            }
        }
    }
    cout<<dp[kk][0][n-1];
    return 0;
}