#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, b;
  cin >> n >> b;
  int a[n], sum = 0, i = 0;
  for (int j = 0; j < n; j++) cin >> a[j];
  sort(a, a + n);
  while (a[i] < 0 && i < b) {
    sum += a[i];
    i++;
  }
  cout << sum * (-1) << endl;
  return 0;
}
