#include <iostream>
#include <vector>

int f(int* begin, int* end, int k)
{
	if (k == 0)
	{
		int sum = 0;
		for (; begin != end; ++begin)
			sum += *begin;
		return sum;
	}
	else
	{
		int sum = 0;		
		for (int* it1 = begin; it1 != end; ++it1)
			for (int* it2 = it1; it2 != end; ++it2)
				sum += f(it1, it2 + 1, k - 1);
		return sum;
	}
}

int main()
{
	int n, k;
	std::cin >> n >> k;

	std::vector<int> arr(n);
	for (auto& A : arr)
		std::cin >> A;

	std::cout << (f(arr.data(), arr.data() + n, k)) % 1000000007;
	return 0;
}