#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const unsigned long long INF = 1e18;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  int x;
  vector<int> v2(n);
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x < 0) {
      v2.push_back(x * (-1));
    }
  }
  sort(v2.begin(), v2.end());
  int ans = 0;
  int i = v2.size() - 1;
  while (m > 0 && i >= 0) {
    ans += v2[i];
    i--;
    m--;
  }
  cout << ans;
}
