#include <bits/stdc++.h>
int main() {
  int n, m;
  int a[1000];
  int sum = 0;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++)
    for (int o = 0; o < n - 1; o++)
      if (a[o] > a[o + 1]) {
        int b = a[o];
        a[o] = a[o + 1];
        a[o + 1] = b;
      }
  int i = 0;
  while ((a[i] <= 0) && (i < m)) {
    sum += a[i];
    i++;
  }
  printf("%d", (-1) * sum);
  return 0;
}
