#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, sum = 0, i;
  cin >> n >> m;
  int arr[n];
  for (i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  for (i = 0; i < m; i++) {
    if (arr[i] < 0) sum = sum + (-1 * arr[i]);
  }
  cout << sum << endl;
  return 0;
}
