#include <iostream>

using namespace std;

struct uin{
    unsigned int* p;
    int duzina;
};

uin podniz(uin niz, int i, int j){
    unsigned int r[j-i];
    int x = 0;
    for(int s = i; s < j; s++) r[x++] = *(niz.p+s);
    uin b = {&r[0], j - i + 1};
    return b;
}

unsigned long long funkcija(uin niz, int n, int k){
    unsigned long long suma = 0;
    if(k == 0) for(int i = 0; i < n; i++) suma += *(niz.p+i);
    else if(n == 1) suma += *(niz.p);
    else for(int i = 0; i < n; i++) for(int j = i; j < n; j++) suma += funkcija(podniz(niz,i,j + 1),j - i + 1,k -1);
    return suma;
}

int main()
{
    int n,k;
    cin >> n >> k;
    unsigned int niz[n];
    for(int i =0;i<n;i++){
        cin >> niz[i];
    }
    uin b = {&niz[0], n};
    cout << funkcija(b, n, k) % 1000000007;
    return 0;
}