#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <bitset>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <set>
#include <map>

using namespace std;

#define for0(i, n) for (ll i = 0; i < n; ++i)
#define for1(i, n) for (ll i = 1; i <= n; ++i)
#define fora(i, v) for (auto i : v)
#define ft first
#define sd second
#define pk push_back
#define pok pop_back
#define ret return
#define con continue
#define sz(v) v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using ll = long long;
using pll = pair <ll, ll>;
using vll = vector <ll>;
using vpll = vector <pll>;
using vvll = vector <vll>;
using pi = pair <int, int>;
using vi = vector <int>;
using vpi = vector <pi>;
using vvi = vector <vector <int>>;

const ll N = 5e5;

ll n, k, m, ans = 0;
ll arr[N + 1];
vll v;

int main() {
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> n >> k;
	v.assign(n - 1, 0);
	for1(i, n - 1) {
		cin >> arr[i];
		v[i - 1] = arr[i];
	}
	cin >> arr[n];
	sort(rall(v));
	for0(i, k - 1)
		ans += v[i] + 1;
	ans += arr[n] + (n + 1 - k);
	cout << ans << "\n";
	ret 0;
}