#include <bits/stdc++.h>
#define endl '\n'
using namespace std;


int main() {
	//freopen("in.txt", "r", stdin);
	ios_base::sync_with_stdio(0);
	cin.tie(0);

    int n, k;
    cin >> n >> k;
    vector<int> niz(n+1);
    for(int i=1; i <= n; i++)
    {
        cin >> niz[i];
    }
    vector<vector<unsigned int> > v(n+1, vector<unsigned int> (n+1,0));
    for(int i = 1; i <= n; i++)
    {
        v[i][i] = niz[i];
    }
    k++;
    while (k--) {

        for(int c = 2; c <= n; c++)
        {
            int i = 1, j = c;
            while(j <= n) {
                v[i][j] += v[i][j-1] + v[i+1][j] - v[i+1][j-1];
                v[i][j] %= 1000000007;
                i++;j++;
            }

        }
    }

    cout << v[1][n] % 1000000007;





	return 0;
}