#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1000000000000000000;
const long long int mod = 1E9 + 7;
void solve() {
  long long int n, m;
  cin >> n >> m;
  long long int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long int sum = 0;
  for (int i = 0; i < m; i++) {
    if (a[i] < 0) {
      sum += -1 * a[i];
    }
  }
  cout << sum << endl;
}
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  ;
  solve();
}
