#include <bits/stdc++.h>
using namespace std;
long long knitX[] = {+2, +2, -2, -2, +1, +1, -1, -1};
long long knitY[] = {+1, -1, +1, -1, +2, -2, +2, -2};
int main() {
  long long n, m, x[200];
  while (scanf("%I64d %I64d", &n, &m) == 2) {
    long long mn = 10000;
    long long mnn = 0;
    for (long long i = 1; i <= n; i++) {
      scanf("%I64d", &x[i]);
    }
    sort(x + 1, x + n + 1);
    long long ans = 0;
    for (long long i = 1; i <= n; i++) {
      if (m <= 0) break;
      if (x[i] < 0) {
        ans -= x[i];
        m--;
      }
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
