#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::fixed;
using std::setprecision;
using std::setw;
int main() {
  double t;
  int n, s = 0, m, q, a[101];
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (a[i] > a[j]) {
        q = a[i];
        a[i] = a[j];
        a[j] = q;
      }
  for (int i = 0; i < m; i++) {
    if (a[i] > 0) break;
    s += a[i];
  }
  t = s;
  s = fabs(t);
  cout << s << endl;
  return 0;
}
