#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n;
  cin >> m >> n;
  int arr[m];
  for (int i = 0; i < m; i++) cin >> arr[i];
  int amount = 0;
  sort(arr, arr + m);
  int count = 0;
  for (int j = 0; j < m; j++) {
    if (arr[j] < 0 && count < n) {
      amount += (-arr[j]);
      count++;
    }
  }
  cout << amount;
  return 0;
}
