#include <bits/stdc++.h>
using namespace std;
int n, m, i, a[100], b[100], s, l, j;
int main() {
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] <= 0) {
      b[j++] = a[i];
      l++;
    }
  }
  sort(b, b + l);
  for (i = 0; i < m; i++) {
    s += b[i];
  }
  cout << abs(s);
}
