#include using namespace std; typedef long long ll; const int MOD=1000000007; #define INF 1LL<<30 #define rep(i,n) for (int i = 0; i < (n); ++i) #define all(x) (x).begin(),(x).end() int main() { int n,k; cin>>n>>k; vector a(n); rep(i,n) cin>>a[i]; sort(all(a)); reverse(all(a)); int ans=0; rep(i,k){ if(a[i]<0) break; ans+=a[i]; } cout<