#include <bits/stdc++.h>
#define K int(2e5 + 5)
#define INF ll(1e17)
#define MOD (long long)(1e9 + 7)
#define endl "\n"
using namespace std;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

ll f(vector<int> &v, int i, int j, int k){
	if (k == 0){
		ll s = 0;
		for (int x = i; x <= j; x++)
			s += v[x];
		return s;
	}
	ll res = 0;
	for (int x = i; x <= j; x++)
		for (int y = x; y <= j; y++)
			res += f(v, x, y, k - 1);
	return res;
}

void solve(){
	int n, k; cin >> n >> k;
	vector<int> v(n);
	for (int &i : v) cin >> i;
	cout << f(v, 0, n - 1, k) << endl;
}
 
int main(){
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
 
    return 0;
}