#include <iostream>
#include <cmath>

int f(int *T, int len, int k) {
	if (k == 0) {
		int sum = 0;
		for (int i = 0; i < len; ++i) {
			sum += T[i];
		}
		return sum;
	}
	else {
		int sum1 = 0;
		for (int i = 0; i < len; ++i) {
			int sum2 = 0;
			for (int j = i; j < len; ++j) {
				sum2 += f(T + i, j - i + 1, k - 1);
			}
			sum1 += sum2;
		}
		return sum1;
	}
}

int main() {
	std::ios_base::sync_with_stdio(false);

	const unsigned int moduo = std::pow(10, 9) + 7;

	int N, k;
	std::cin >> N >> k;

	int* A = new int[N];
	for (int i = 0; i < N; ++i) {
		std::cin >> A[i];
	}

	std::cout << f(A, N, k) % moduo;

	return 0;
}