#include <bits/stdc++.h>
using namespace std;
struct greater {
  template <class T>
  bool operator()(T const &a, T const &b) const {
    return a > b;
  }
};
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    long long arr[n];
    std::vector<long long> v;
    for (long long i = 0; i < n; ++i) {
      cin >> arr[i];
      if (arr[i] < 0) v.push_back(arr[i]);
    }
    long long l = v.size();
    long long ans = 0;
    sort(v.begin(), v.end());
    for (long long i = 0; i < min(m, l); ++i) {
      ans += abs(v[i]);
    }
    cout << ans;
  }
  return 0;
}
