#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, a[105] = {0};
  while (cin >> n >> m) {
    for (int i = 0; i < n; i++) cin >> a[i];
    int s = 0;
    sort(a, a + n);
    for (int i = 0; i < m; i++)
      if (a[i] > 0)
        break;
      else
        s -= a[i];
    cout << s << endl;
  }
  return 0;
}
