#include <bits/stdc++.h>
signed main() {
  long long muda = 0, mudaa[100], sum = 0, i, ii, n = 0, k = 0, a[1001];
  scanf("%lld %lld", &n, &k);
  for (i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    sum += a[i];
  }
  for (i = 0; i < n - k; i++) {
    for (ii = 0; ii < n; ii++) {
      if (a[ii] > mudaa[i]) {
        mudaa[i] = a[ii];
      }
    }
    for (ii = 0; ii < n; ii++) {
      if (mudaa[i] == a[ii]) {
        a[ii] = 0;
      }
    }
    muda += mudaa[i];
  }
  printf("%lld\n", sum - muda);
  return (0);
}
