#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
int main() {
  int n, m, i, ans = 0, cnt = 0;
  cin >> n >> m;
  int a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (i = 0; i < n; i++) {
    if (a[i] < 0 and cnt < m) {
      ans -= a[i];
      cnt++;
    } else {
      break;
    }
  }
  cout << ans;
  return 0;
}
