#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, v[110], s = 0;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &v[i]);
  sort(v, v + n);
  for (int i = 0; i < n; i++) {
    if (v[i] < 0 && m > 0) {
      s += -v[i];
      m--;
    } else
      break;
  }
  printf("%d\n", s);
  return 0;
}
