#include <bits/stdc++.h>
using namespace std;
typedef unsigned int UI;
typedef long int LI;
typedef unsigned long int ULI;
typedef long long int LL;
typedef unsigned long long int ULL;
LL mod = 1e9 + 7;
inline int scanInt() {
  int n = 0;
  char ch = getchar();
  int sign = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') sign = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    n = (n << 1) + (n << 3) + (int)(ch - '0');
    ch = getchar();
  }
  return n * sign;
}
inline LL scanLong() {
  LL n = 0;
  char ch = getchar();
  LL sign = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') sign = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    n = (n << 1) + (n << 3) + (LL)(ch - '0');
    ch = getchar();
  }
  return n * sign;
}
int main() {
  LL n = scanLong();
  ;
  LL m = scanLong();
  ;
  LL arr[n];
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n)))
    arr[i] = scanLong();
  sort(arr, arr + n);
  LL idx = lower_bound(arr, arr + n, (LL)0) - arr;
  LL ans = 0;
  for (__typeof((LL)min(m, idx)) i = (0) - ((0) > ((LL)min(m, idx)));
       i != ((LL)min(m, idx)) - ((0) > ((LL)min(m, idx)));
       i += 1 - 2 * ((0) > ((LL)min(m, idx))))
    ans += arr[i];
  printf("%lld ", abs(ans));
  printf("\n");
}
