#include #include #include using namespace std; int main() { int n, k; cin >> n >> k; vector a(n); for (int i=0; i> a[i]; sort(a.begin(), a.end()); int ans = 0; for (int i=n-1; i>=k-1&&a[i]>0; i--) ans += a[i]; cout << ans << endl; }