#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int fun(int a[], int k, int l, int r){
	long long br2=0;
	long long ostatak=10*10*10*10*10*10*10*10*10+7;
	if(k==0){
		long long br=0;
		for(int i=l;i<=r;i++){
			br+=a[i];
		}
		br=br%ostatak;
		return br;
	}else{
		for(int i=l;i<=r;i++){
			int k2;
			for(int j=i;j<=r;j++){
				int b[j-i+1];
				for(int x=0;x<=(j-i);x++){
					b[x]=a[i+x];
				}
				k2=k;
				k2--;
				long long p;
				p=fun(b,k2,0,(j-i));
				br2+=p;
				br2=br2%ostatak;
			}
		}		
	}
	return br2;	
}

int main(int argc, char** argv) {
	
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	cout<<fun(a,k,0,(n-1));

	return 0;
}