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