#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x[100], sum = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  for (int i = 0; i < m; i++) {
    int a = i, min = x[i];
    for (int j = i; j < n; j++) {
      if (x[j] < min) {
        a = j;
        min = x[j];
      }
    }
    if (x[a] > 0) break;
    sum -= x[a];
    x[a] = x[i];
  }
  cout << sum << endl;
  return 0;
}
