#include <iostream>
#define forn(i, n) for (int i = 0; i < n; i++)
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
typedef long long ll;
const int oo = 3e2+7;
const ll mod = 1e9+7;
ll dp[oo][oo][oo];
ll getdp(int i, int j, int k);
int n,k;
ll a[oo];
ll prefix[oo];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    cin >> n >> k;
    forn(i, n) cin >> a[i];
    ll sum = 0;
    forn(i, n) {
        sum+=a[i];
        sum%=mod;
        prefix[i+1]=sum;
    }
    prefix[0]=0;
    forn(i, n) forn(j, n) forn(l, k) dp[i][j][l]=-1;
    forn(i, n) forn(j, n) dp[i][j][k] = 0;
    dp[0][n-1][k]=1;
    sum = 0;
    forn(i, n) for (int j = i; j<n; j++) {
        sum+=getdp(i, j, 0)*(prefix[j+1]-prefix[i]);
        sum%=mod;
    }
    cout << sum << endl;
}
ll getdp(int i, int j, int l) {
    if (dp[i][j][l]!=-1) return dp[i][j][l];
    dp[i][j][l] = 0;
    for (int lp = i; lp>=0; lp--) for (int rp = j; rp < n; rp++) {
        dp[i][j][l]+=getdp(lp, rp, l+1);
        dp[i][j][l]%=mod;
    }
    return dp[i][j][l];
}