#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

/*ll suma(vector<ll> a){
    ll rez = 0;
    for(ll i = 0;i < a.size();i++)
        rez += a[i];
    return rez;
}

ll resenje(vector<ll> a, ll k){
    if(k == 0)
        return suma(a);

}*/

ll rezultat = 0;

ll suma(int a[], int n){
    ll rez = 0;
    //for(int i = 0;i < n;i++)
    //    rez += a[i]*(i+1)*(n-i);
    for(int i = 0;i < n;i++) rez += a[i];
    return rez;
}

void resenje(int a[], int n, int k){
    if(k == 0){
        rezultat += suma(a, n); //prepravi u sumu niza umesto svih podnizova
        return;
    }
    else{
        int pom[n], p = 0;
        for(int i = 0;i < n;i++){
            for(int j = i;j < n;j++){
                pom[p++] = a[j];
                resenje(pom, p, k - 1);
            }
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int a[n];
    //int b[n];
    //vector<ll> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        //if(i == 0) b[i] = a[i];
        //else b[i] = a[i] + b[i-1];
    }
    //for(int i = 0;i < n;i++)
    //    cout << b[i] << " ";
    resenje(a, n, k);
    cout << rezultat;
    return 0;
}