#include <bits/stdc++.h>
using namespace std;
int n, m, ans;
int a[100050];
int main() {
  memset(a, 0, sizeof(a));
  ans = 0;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  for (int i = 0; i < m; i++)
    if (a[i] < 0) ans += a[i] * (-1);
  printf("%d\n", ans);
  return 0;
}
