
#include <iostream>
#include <limits>
#include <chrono>
#include <random>
#include <iomanip>
#include <algorithm>
#include <chrono>
#include <random>
#include <math.h>
#include <set>
using namespace std;
#define int long long
signed main()
{
	int n, k;
	cin >> n >> k;
	vector <int> vec(n);
	int sum = n;
	for (int i = 0;i < n;i++)cin >> vec[i];
	multiset <int> st;
	for (int i = 0;i < n - 1;i++)st.insert(vec[i]);
	sum += vec.back();
	while (st.size() >= k) {
		st.erase(st.begin());
	}
	while (st.size()) {
		sum += *st.begin();
		st.erase(st.begin());
	}
	cout << sum;
}
