#include <bits/stdc++.h>
using namespace std;
const int MN = 100 + 10;
int arr[MN];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> arr[i];
  int sum = 0;
  sort(arr, arr + n);
  for (int i = 0; i < min(n, m); i++) {
    if (arr[i] >= 0) break;
    sum += abs(arr[i]);
  }
  cout << sum;
  return 0;
}
