#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y;
  cin >> x >> y;
  int arr[x];
  for (int i = 0; i < x; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + x);
  int sum = 0;
  for (int i = 0; i < y; i++) {
    if (arr[i] >= 0) {
      continue;
    } else {
      sum += abs(arr[i]);
    }
  }
  cout << sum;
  return 0;
}
