#include<iostream>
using namespace std;
 
int main()
{
    // get a integer
    int N, k;
    cin >> N >> k;
  	vector<int> arr(N);
  	int a;
    // get two integers separated with half-width break
  	for (int i=0; i<N; i++) {
      	cin >> a;
      	arr.push_back(a);
    }
  	priority_queue<int> pq;
  	for (int i=0; i<N; i++) {
      pq.push(arr[i]);
      if (i>=k)
        pq.pop();
    }
  	int res = 0;
  	while (!pq.empty()) {
      	res += pq.top();
      	pq.pop();
    }
  	cout << res;
    return 0;
}