#include <bits/stdc++.h>
using namespace std;
long long power(long long b, long long n) {
  if (b == 0 && n == 0) return -1;
  if (b == 0 || b == 1) return b;
  if (n == 0)
    return 1;
  else if (n % 2)
    return b * power(b, n / 2) * power(b, n / 2);
  else
    return power(b, n / 2) * power(b, n / 2);
}
void solve() {
  long long n, m;
  scanf("%I64d %I64d", &n, &m);
  vector<long long> v;
  for (long long i = 0; i < n; i++) {
    long long x;
    scanf("%I64d", &x);
    v.push_back(x);
  }
  sort((v).begin(), (v).end());
  long long profit = 0;
  for (long long i = 0; i < m; i++) {
    if (v[i] <= 0)
      profit += abs(v[i]);
    else
      break;
  }
  printf("%I64d", profit);
}
int main() { solve(); }
