#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;

vector<ll> sveSume;
void napraviSume(ll a[], int n) {
    sveSume.resize(n);
    sveSume[0] = a[0]%mod;
    for (int i = 1; i < n; ++i) {
        sveSume[i] = (sveSume[i-1]%mod+a[i]%mod)%mod;
    }
}

int f(ll a[], int k, int s, int n) {

    if (!k) {
        ll sum = 0;
        return sveSume[n]-sveSume[s]+(a[s]%mod);
    } else {
        ll sum = 0;
        int kk = k-1;
        for (int i = s; i <= n; ++i) {
            for (int j = i; j <= n; ++j) {
                sum += f(a, kk, i, j);
            }
        }
        return sum;
    }

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, k;
    cin >> n >> k;

    ll a[n];
    for (int i = 0; i < n; ++i) cin >> a[i];

    napraviSume(a, n);
    cout << f(a, k, 0, n-1);

    return 0;
}