#include <bits/stdc++.h>
using namespace std;
int main() {
  int tvs, carry, counter = 0, answer = 0;
  cin >> tvs >> carry;
  int arr[tvs];
  for (int i = 0; i < tvs; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + tvs);
  for (int i = 0; i < tvs; i++) {
    if (counter == carry || arr[i] > 0) {
      break;
    }
    answer += abs(arr[i]);
    counter++;
  }
  cout << answer;
  return 0;
}
