#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v;
  vector<int> v1;
  int s = 0, c = 0;
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    v.push_back(p);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    if (v[i] < 0) {
      s -= v[i];
      c++;
      if (c == m) {
        cout << s;
        return 0;
      }
    }
  }
  cout << s;
}
