#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> a;
int main() {
  cin >> n >> m;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (a.at(i) < 0) ans = ans + a.at(i) * -1;
  }
  cout << ans;
  return 0;
}
