#include <bits/stdc++.h>

using namespace std;
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx2,avx,bmi2")
//#include "ext/pb_ds/assoc_container.hpp"
//#include "ext/pb_ds/tree_policy.hpp"
//using namespace __gnu_pbds;
//template<class T> using oredered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long

const int maxn = 1e5, inf = 8e18, mod = 1e9 + 7;

bool comp(pair<int, int> a, pair<int, int> b) {
    if (a.first == b.first) {
        return a.second  > b.second;
    }
    return a.first > b.first;
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        v[i] = {a[i], i};
    }
    sort(v.begin(), v.end(), comp);
    int res = 0;
    for (int i = 0; i < k - 1; i++) {
        res += v[i].first + 1;
    }
    res += v[k - 1].first + 1;
    for (int i = k; i < n; i++) {
        res += v[i].second < v[1].second;
    }
    cout << res << endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
//    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}
// wow1