#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < int(n); i++) cin >> a[i];
  sort(a.begin(), a.end());
  int l = 0;
  long long income = 0;
  while (m && a[l] < 0) income -= a[l], l++, m--;
  cout << income << endl;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
