#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m, negative_counter = 0;
  scanf("%d %d", &n, &m);
  vector<int> A;
  for (int i = 0; i < n; i++) {
    int temp;
    scanf("%d", &temp);
    A.push_back(temp);
    if (temp < 0) negative_counter++;
  }
  sort(A.begin(), A.end());
  if (negative_counter == 0)
    printf("0\n");
  else if (negative_counter <= m)
    cout << abs(accumulate(A.begin(), A.begin() + negative_counter, 0)) << endl;
  else if (negative_counter > m)
    cout << abs(accumulate(A.begin(), A.begin() + m, 0)) << endl;
  return 0;
}
