#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;

vector<vector<vector<ull>>> dp;
vector<vector<vector<bool>>> vis;

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


void solve(){
	int n, k; cin >> n >> k;
	vector<ull> v(n);
	dp.resize(n, vector<vector<ull>>(n, vector<ull>(k + 1)));
	vis.resize(n, vector<vector<bool>>(n, vector<bool>(k + 1, 0)));
	for (ull &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;
}