#include <bits/stdc++.h>
using namespace std;
int n;
int Min(int *ara) {
  int x = ara[0], index = 0;
  for (int i = 1; i < n; i++) {
    if (x > ara[i]) {
      x = ara[i];
      index = i;
    }
  }
  ara[index] = 1001;
  return x;
}
int main() {
  int m;
  cin >> n >> m;
  int ara[n], sum = 0;
  for (int i = 0; i < n; i++) cin >> ara[i];
  for (int i = 0; i < m; i++) {
    int t = Min(ara);
    if (t <= 0) {
      sum = sum + t;
    }
    t = 0;
  }
  cout << abs(sum) << endl;
}
