#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  int temp = m;
  int a[n];
  vector<int> v;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    if (a[i] < 0) {
      v.push_back(abs(a[i]));
    }
  }
  sort(v.begin(), v.end(), greater<int>());
  int p = v.size();
  int ran = min(p, temp);
  for (int i = 0; i < ran; i++) ans += v[i];
  cout << ans;
}
