#include <iostream>

using namespace std;

long long sab(unsigned int x, unsigned int y){
    long long rez = 0;
    rez = (rez + (x % 1000000007)) % 1000000007;
    rez = (rez + (y % 1000000007)) % 1000000007;
    return rez;
}

void dodaj(unsigned int a[], int n, int k, unsigned int &res){
    if(k == 0){
        for(int m = 0; m < n; m++)
            res = sab(res, a[m]);
    }
    else{
        for(int i = 0; i < n; i++)
            for(int j = i; j < n; j++)
            {
                unsigned int b[j-i+1];
                int m = 0;
                int m1 = i;
                while(m <= j-i){
                    b[m] = a[m1];
                    m++;
                    m1++;
                }
                dodaj(b,j-i+1,k-1,res);
            }
    }
}

int main()
{
    int n, k;
    cin>>n>>k;
    unsigned int a[n];
    for(int i = 0; i < n; i++)
        cin>>a[i];
    unsigned int res = 0;
    dodaj(a,n,k,res);
    cout<<res;
    return 0;
}