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