#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <chrono>
using namespace std;
using ll = long long;
using lld = long double;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif;
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ll msk = (1 << n);
    ll ans = 0;
    vector<ll> w;
    for (ll m = 0; m < msk; ++m) {
        set<ll> pos;
        ll res = 0;
        for (int i = 0; i < n; ++i) {
            if (m & (1 << i)) {
                pos.insert(i);
                res += a[i] + 1;
            }
        }
        if ((int)pos.size() != k - 1)
            continue;
        ll cnt = 0, mx = 0;
        for (int i = 0; i < n; ++i) {
            if (!(m & (1 << i))) {
                cnt++;
                mx = max(mx, cnt + a[i]);
            }
        }
        if (res > ans) {
            ans = res;
        }
    }
    cout << ans << '\n';
}