#include <bits/stdc++.h>

using namespace std;

const int64_t mod = 1000000007;

int64_t bug(const vector<int64_t> &prefiksi, vector<vector<vector<int64_t>>> &DOBAR, int32_t i, int32_t j, int32_t k)
{
    if(DOBAR[i][j][k] != -1)
        return DOBAR[i][j][k];

    if(k == 0)
    {
        return DOBAR[i][j][k] = (prefiksi[j] - prefiksi[i - 1]) % mod;
    }
    else
    {
        int64_t momenat = 0;
        for(auto ii = i; ii <= j; ii++)
            for(auto jj = ii; jj <= j; jj++)
                momenat = ((momenat % mod) + bug(prefiksi, DOBAR, ii, jj, k - 1)) % mod;

        return DOBAR[i][j][k] = momenat;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);

    int32_t n, k;
    cin >> n >> k;
    vector<int64_t> prefiksi(n + 1, 0);
    vector<vector<vector<int64_t>>> hmmm(n + 1, vector<vector<int64_t>>(n + 1, vector<int64_t>(k + 1, -1)));

    for(auto i = 1; i <= n; i++)
    {
        int64_t a;
        cin >> a;
        prefiksi[i] = a % mod;
    }

    for(auto i = 1; i <= n; i++)
        prefiksi[i] = (prefiksi[i] + prefiksi[i - 1]) % mod;

    cout << bug(prefiksi, hmmm, 1, n, k) << '\n';

    cout.flush();
    return 0;
}