#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, c = 0, r, sum = 0;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < 0) {
      c++;
    }
  }
  sort(a, a + n);
  for (int i = 0; i < min(m, c); i++) {
    sum += abs(a[i]);
  }
  cout << sum << endl;
  return 0;
}
