#include <bits/stdc++.h>

#define N 200'000

constexpr size_t sum(size_t* niz, size_t len) {
	size_t rez = 0;
	for (size_t i = 0; i < len; ++i)
		rez += niz[i];
	return rez;
}

constexpr size_t f(size_t* niz, size_t k, size_t len) {
	if (!k) {
		return sum(niz, len);
	}

	size_t outer_sum = 0;
	for (size_t i = 0; i < len; ++i) {
		size_t inner_sum = 0;
		for (size_t j = i; j < len; ++j) {
			inner_sum += f(niz + i, k - 1, j - i + 1);
		}
		outer_sum += inner_sum;
	}
	return outer_sum;
}

auto main() -> int {
	std::ios_base::sync_with_stdio(false);

	size_t n, k, a[N];

	std::cin >> n >> k;
	for (size_t i = 0; i < n; ++i) {
		std::cin >> a[i];
	}

	const auto pobednik = f(a, k, n);
	std::cout << pobednik % 1'000'000'007 << '\n';
}