#include <bits/stdc++.h>
using namespace std;
int main() {
  int forSale, carry;
  cin >> forSale >> carry;
  vector<int> prices;
  for (int _ = 0; _ < forSale; _++) {
    int price;
    cin >> price;
    prices.push_back(price);
  }
  sort(begin(prices), end(prices));
  int profit = 0;
  for (int i = 0; i < carry; i++) {
    if (i == prices.size() || prices[i] >= 0) break;
    profit += -1 * prices[i];
  }
  cout << profit << endl;
}
