#include <bits/stdc++.h>

using namespace std;
typedef long long ll;


void solve() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (ll i = 0; i < n; ++i) cin >> a[i];
    ll answer1 = 0;
    vector<ll> b = a;
    sort(b.begin(), b.end());
    int j = 0;
    for (int i = 0; i < n; ++i) if (a[i] >= b[n - k]) j = i;
    for (int i = n - 1; i > n - k - 1; --i) answer1 += b[i];

    sort(a.begin(), --a.end());
    ll answer = 0;
    for (ll i = n - 1; i > n - 1 - k; --i) answer += a[i];
    cout << max(answer + n, answer1 + j + 1) << "\n";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll t = 1;
    // cin >> t;
    while (t--) solve();
}
