#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> vec;
  vector<char> cvec;
  vector<string> svec;
  int a, b, x[100 * 10], y[100 * 10], z, count = 0;
  string str1[10], str2;
  char c[10];
  cin >> a;
  cin >> b;
  int tmp = 0;
  for (long long i = 0; i < (long long)(a); i++) cin >> x[i];
  for (int i = 0; i < a; i++) {
    for (int j = a - 1; j > i; j--) {
      if (x[j] < x[j - 1]) {
        tmp = x[j];
        x[j] = x[j - 1];
        x[j - 1] = tmp;
      }
    }
  }
  for (long long i = a - b + 1 - 1; i >= 0; i--) count += x[i];
  auto answer = count;
  cout << answer << endl;
  return 0;
}
