#include <bits/stdc++.h>
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
using namespace std;
using ll = long long;
using ld = long double;
const ll MOD = 1e+9 + 7;
const ll INF = LLONG_MAX;
const int N = (int)2e+5 + 8;
template <typename T>
string itos(T i) {
  stringstream second;
  second << i;
  return second.str();
}
int main() {
  ios_base ::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  ll n, m;
  cin >> n >> m;
  ll arr[n];
  for (ll i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  ll sum = 0;
  for (ll i = 0; i < m; i++) {
    if (abs(arr[i]) != arr[i]) sum += abs(arr[i]);
  }
  cout << sum;
}
