#include<iostream>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

#define ll long long

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (k == n) {
        ll sum = 0;
        for (ll i = 0; i < n; i++) {
            sum += a[i] + 1;
        }
        cout << sum;
        return 0;
    }
    ll answer = 0;
    for (ll i = 0; i < n; i++) {
        vector<pair<ll, ll>> a1;
        for (ll j = 0; j < n; j++) {
            if (i == j) {
                continue;
            }
            a1.push_back({a[j], j});
            sort(a1.rbegin(), a1.rend());
        }
        set<ll> s1;
        ll answer1 = 0;
        for (ll j = 0; j < k - 1; j++) {
            s1.insert(a1[j].second);
            answer1 += a1[j].first + 1;
        }
        vector<ll> b;
        for (ll j = 0; j < n; j++) {
            if (s1.find(j) == s1.end()) {
                b.push_back(a[j]);
            }
        }
        ll max1 = 0;
        for (ll j = 0; j < b.size(); j++) {
            max1 = max(max1, b[j] + j + 1);
        }
        answer1 += max1;
        answer = max(answer, answer1);
    }
    cout << answer;
}