#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a[100001], i, j, c = 0, x = 0, flag = 0;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (i = 0; i < m; i++) {
    if (a[i] < 0) c += abs(a[i]);
  }
  cout << c << endl;
}
