#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define fi first
#define se second
#define ld long double
#define N_5 100010
#define N_6 1000010
#define N_7 10000010
#define N_8 100000010
#define N_9 1000000010
#define ost 1000000007
#define ldb long double
#define ull unsigned long long
using namespace std;
vector<int>v;
int dp[301][301][301];

int resi(int l, int r, int k) {
    if ( dp[l][r][k] ) return dp[l][r][k];
    if ( k == 0 ) {
        int res = 0 ;
        for (int i = l ; i <= r ; i++ ) {
            res += v[i];
        }
        dp[l][r][k] = res ;
    }
    else {
        int res = 0 ;
        for ( int i = l ; i <= r ; i++ ) {
            for ( int j = i ; j <= r ; j++ ) {
                res += resi(i,j,k-1);
                res %= ost ;
            }
        }
        dp[l][r][k] = res ;
    }
    return dp[l][r][k];
}

void solve() {
    int n , k ;
    cin >> n >> k ;
    v.resize(n);
    for (int i = 0 ; i < n ; i++ ) {
        cin >> v[i];
    }
    if ( k == 1 ) {
        ll res = 0 ;
        vector<int>parc(n+1);
        parc[0] = 0 ;
        for (int i = 1 ; i <= n ; i++ ) {
            parc[i] = parc[i-1];
            parc[i] += v[i-1];
            parc[i] %= ost;
        }

        for ( int i = 0 ; i <= n ; i++ ) {
            for (int j = i+1 ; j <= n ; j++ ) {
                res += parc[j]-parc[i];
                res %= ost ;
                //cout << i << ' ' << j << ' ' << parc[j]-parc[i] << endl ;
            }
        }

        cout << res ;
    }
    else if (k == 0) {
        ll res = 0 ;
        for (int i = 0 ; i < n ; i++ ) {
            res += v[i];
        }
        cout << res%ost;
    }
    else {
        resi(0,n-1,k);
        cout << dp[0][n-1][k];
    }
} 
 
 
int main () {
    
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t =1;
    //cin >>t ;
    while(t--) 
        solve();
}