#include using namespace std; int main(){ int n , k; cin >> n >> k; vector a(n); for(int i = 0;i > a[i]; sort(begin(a),end(a),greater()); int sum = 0; for(int i = 0;i < k;i++){ if(a[i]<0){ if(i == 0){ sum += a[i]; } break; } sum += a[i]; } cout << sum << endl; return 0; }