#include <iostream>

using namespace std;

long long N, k;
int A[2000];

long long sum(long long starting_point, long long ending_point) {
	long long sum = 0;
	
	for (long long i = starting_point; i<=ending_point; i++) {
		sum += A[i];
	}
	return sum;
}

int main () {
	
	long long int sum_sums = 0;
	
	scanf("%lld%lld", &N, &k);
	
	for (int i = 0; i<N; i++) {
		scanf("%d", &A[i]);
	}
	
	if (k == 0) {
		printf("%lld ", sum(0, N)%(1000000000+7));
	} else {
			for (long long j = 0; j<N; j++) {
				for (long long i = 0; i<N; i++) {
					sum_sums += sum(j, i);
				}
			}
			printf("%lld ", sum_sums%(1000000000+7));
		}
	
	return 0;
}