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