#include <iostream>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <bitset>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <random>

using namespace std;

random_device rd;
mt19937 rnd(rd());

#define int long long

void solve() {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int res = 0;
    auto cop = a;
    for (int i = k - 1; i < n; i++) {
        a = cop;
        sort(a.begin(), a.begin() + i);
        reverse(a.begin(), a.begin() + i);
        int temp = 0;
        for (int j = 0; j < k - 1; j++) {
            temp += a[j];
        }
        temp += a[i];
        temp += i + 1;
        res = max(res, temp);
    }
    cout << res;
    return;
    sort(a.begin(), a.begin() + n - 1);
    int r1 = k;
    for (int i = n - k; i < n; i++) {
        r1 += a[i];
    }
    r1 += n - k;

    cout << res;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}
