#include <iostream>
#include <vector>

using namespace std;

long long Suma(vector<long long> a, int l, int d) {
    int suma = 0;
    for (int i = l; i <= d; i++) {
        suma += a[i];
    }

    return suma;
}

long long F(vector<long long> a, int k, long long suma, int l, int d) {
    if (k == 0) {
        return Suma(a, l, d);
    }

    for (int i = 0; i < a.size(); i++) {
        for (int j = i; j < a.size(); j++) {
            suma += F(a, k - 1, suma, i, j);
        }
    }

    return suma;
}

int main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);
    int n, k;
    cin >> n >> k;

    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    long long p = F(a, k, 0, 0, n - 1);

    cout << p % 1000000007;

    return 0;
}