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