#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, i, x;
  cin >> n >> m;
  vector<int> vc;
  for (i = 0; i < n; i++) {
    cin >> x;
    vc.push_back(x);
  }
  sort(vc.begin(), vc.end());
  i = 0;
  int as = 0;
  while (m--) {
    if (vc[i] < 0) {
      as -= vc[i];
    } else
      break;
    i++;
  }
  cout << as;
  return 0;
}
