#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 9;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n);
  for (long long i = (long long)(0); i < (long long)(n); ++i) cin >> a[i];
  sort(a.begin(), a.end());
  long long ans = 0;
  for (long long i = (long long)(0); i < (long long)(n); ++i) {
    if (!m) break;
    if (a[i] < 0) ans += a[i];
    --m;
  }
  cout << abs(ans);
  return 0;
}
