#ifdef LOCAL
#pragma optimize("", off)
#include "localstd1.h"
#else
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/allocator.h>
#pragma GCC target("avx2,bmi,bmi2")
#include <bits/stdc++.h>
#endif

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define all(a) (a).begin(), (a).end()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n, k; cin >> n >> k;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	auto b = a;
	sort(all(b));
	int kth = b[n - k];
	ll ans = accumulate(b.end() - k, b.end(), ll(0));
	ans += n;
	if (a.back() < kth) ans--;
	cout << ans;
	return 0;
}