#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  int n, m;
  cin >> n >> m;
  vector<int> v;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (a < 0) v.push_back(a);
  }
  sort(v.begin(), v.end());
  int s = 0;
  for (int i = 0; i < m; ++i) {
    if (i < v.size())
      s += -v[i];
    else
      break;
  }
  cout << s << endl;
  return 0;
}
