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