#include <bits/stdc++.h>
using namespace std;
vector<long long int> v, v1, v2, v3;
string s, s1, s2, s3;
int main() {
  long long int a[100001], b[100001], c, d, i, j, k, l, m, n, p, q, t,
      ct = 0, ct1 = 0, ct2 = 0, ck = 0, ck1 = 0, ck2 = 0, ln, ln1, start, end,
      mid;
  long long int a1 = 0, a2 = 0, a3 = 0, a4 = 0, sum = 0, sum1 = 0, max1, max2,
                min1, min2;
  double x, y, z;
  char ch, ch1, ch2;
  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) a1 = a1 + abs(a[i]);
  }
  cout << a1;
  return 0;
}
