#include <iostream>
//#include <iomanip>
#include <cmath>
//#include <algorithm>
//#include <string>
//#include <vector>
//#include <ctime>
//#include <cstdlib>
//#include <limits>
//#include <mycpp.h>

#define MOD 1000000007

typedef long long ll;

using namespace std;

ll Suma(int a[],int poc, int kraj)
{
	ll S=0;
	for(;poc<=kraj;poc++)
		S+=a[poc];
}

ll f(int a[],int k, int poc, int kraj)
{
	if(k==0)
	{
		ll S=0;
		for(int i=poc;i<=kraj;i++)
			S+=a[i];
		return S%MOD;
	}
	else
	{
		ll S=0;
		for(int i=poc;i<=kraj;i++)
			for(int j=i;j<=kraj;j++)
				S+=f(a,k-1,i,j);
		return S%MOD;
	}
}

int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	cout<<f(a,k,0,n-1)%MOD;
}