#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

unsigned long long int suma(vector <unsigned int> niz){
    int rez=0;
    for(int i=0; i<niz.size(); i++){
        rez+=niz[i];
    }
    return rez;
}

unsigned long long int funkcija(vector <unsigned int> niz, unsigned k){
    if(k==0){
        return suma(niz);
    }else{
        unsigned long long int ret=0;
        for(int a=0; a<niz.size(); a++){
            for(int b=a; b<niz.size(); b++){
                vector <unsigned int> noviNiz;
                for(int i=a; i<b; i++){
                    noviNiz.push_back(niz[i]);
                }
                ret+=funkcija(noviNiz, k-1);
            }
        }
        return ret;
    }
}

int main()
{
    unsigned int duzinaNiza;
    cin>>duzinaNiza;
    vector <unsigned int> niz (duzinaNiza);
    unsigned int k;
    cin>>k;

    for(int i=0; i<duzinaNiza; i++){
        cin>>niz[i];
    }

    cout<<funkcija(niz,k)%(unsigned long long int)(pow(10,9)+7);
}