#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, count = 0, sum = 0, num;
  cin >> n >> m;
  vector<int> nums;
  for (int i = 0; i < n; i++) {
    cin >> num;
    if (num < 0) nums.push_back(num);
  }
  if (nums.empty()) {
    cout << 0;
    return 0;
  }
  sort(nums.begin(), nums.end());
  while ((count < m) && (count < nums.size())) sum -= nums[count++];
  cout << sum;
}
