#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
int n, m, ans;
int main() {
  scanf("%d %d", &n, &m);
  vector<int> v(n);
  for (int i = 0; i < n; i++) scanf("%d", &v[i]);
  sort(v.begin(), v.end());
  for (int i = 0; i < m; i++)
    if (v[i] < 0) ans += abs(v[i]);
  printf("%d\n", ans);
  return 0;
}
