#include <iostream>
#include <vector>

using namespace std;


int hehe(vector<int>& a, int l, int r, int k) {
    int w = 0;
    if (k > 0)
        for (int i = l;i < r;i++)
            for (int j = i + 1;j < r + 1;j++)
                w += hehe(a, i, j, k - 1);
    else
        while (l < r) {
            w = w + (a[l] % 1000000007);
            l++;
        }
    return w;
}

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0;i < n;i++) {
        cin >> a[i];
    }
    int w = hehe(a, 0, n, k);
    cout << w << endl;
}