#include #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, a, b) for (int i = (a); i < (b); ++i) #define PI acos(-1) #define pcnt __builtin_popcountll #define rng(a) a.begin(), a.end() #define rrng(a) a.rbegin(), a.rend() #define sz(x) (int)(x).size() #define v(T) vector #define vv(T) v(v(T)) #define fi first #define se second using namespace std; using ll = long long; using ld = long double; using P = pair; using LP = pair; using vi = vector; using vvi = vector; using vl = vector; using vvl = vector; templateinline istream& operator>>(istream&i,v(T)&v) {rep(j,sz(v))i>>v[j];return i;} templateinline istream& operator>>(istream&i,pair&v) {return i>>v.fi>>v.se;} template inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; } ll INF = 1001001001; ll LINF = 1001001001001001001ll; int main() { cin.tie(0); ios::sync_with_stdio(false); ll n, k; cin>>n>>k; vl as(n); cin>>as; sort(rrng(as)); ll ans = as[0]; rep(i, k - 1) { if (as[i + 1] < 0) break; ans += as[i + 1]; } cout<