#include <iostream>
#include <vector>
using namespace std;
#define MOD 1000000007

int dp[301][301][301];

long long bug(const vector<int>& a, int l, int d, int k)
{
	if (dp[l][d][k] != 0)
		return dp[l][d][k];
	if (k == 0)
	{
		long long sum = 0;
		for (int i = l; i <= d; i++)
			sum = (sum + a[i]) % MOD;
		dp[l][d][k] = sum;
		return sum;
	}

	long long sum = 0;
	for (int i = l; i <= d; i++)
	{
		for (int j = i; j <= d; j++)
		{
			sum = (sum + bug(a, i, j, k - 1)) % MOD;
		}
	}
	dp[l][d][k] = sum;
	return sum;
}

int main()
{
	int n, k; cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];

	cout << bug(a, 0, n - 1, k) << endl;
}