#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<cmath>
#include<set>
using namespace std;
/*bool chek(vector<int> a, long long pans, int k, vector<pair<int, int> > s, long long maxans, vector<int> s2) {
	vector<int> c;
	vector<int> t;
	t = s2;
	t.resize(k);
	c = a;
	sort(c.begin(), c.begin() + k);
	if (c == s2) {
		return(true);
	}
	else {
		return(false);
	}

}*/
int main() {
	int n, k;
	cin >> n >> k;
	long long maxans;
	maxans = k+2;
	vector<int> a(n);
	vector<int> s2(n);
	vector<pair<int, int> > s(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		s[i] = make_pair(a[i], i);
		s2[i] = a[i];
		maxans += a[i];
	}
	sort(s2.begin(), s2.begin() + n);
	sort(s.begin(), s.begin() + n);
	//cout << maxans << "-maxans \n";
	for (int i = 0; i < k-1; i++) {
		maxans -= s2[i];
		//cout << s2[i] << " ";
	}
	for (int i = 0; i < k; i++) {
		if (a[n - 1] == s2[i]) {
			cout << maxans - 1;
			return 0;
		}
	}
	cout << maxans;
}
