#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 12;

#define int long long

mt19937_64 rng (time (0));
int n, k, a[N], used[N];
int ans = 0, sum = 0;
vector<int> val;

void rec (int pos, int cnt, int mx = 0) {
    if (cnt == n - k + 1) {
        int cur = 0;
        for (int i = 1; i <= n; ++i) {
            if (!used[i]) cur += a[i] + 1;
        }
//        if (cur < sum) return;
        ans = max (ans, cur + mx);
        return;
    }
    if (pos > n) return;
    for (int nxt = pos; nxt <= n; ++nxt) {
        used[nxt] = 1;
        rec (nxt + 1, cnt + 1, max (mx, a[nxt] + cnt + 1));
        used[nxt] = 0;
    }
}
signed main() {
#ifdef local
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // local
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> a[i], val.push_back (a[i]);
    sort (rbegin (val), rend (val));
    while ((int)val.size() > k - 1) val.pop_back();
    for (auto it : val) sum += it + 1;
    rec (1, 0);
    cout << ans << '\n';
}
