#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 = a[n-1]; for (int i=n-2; i>=n-k&&a[i]>0; i--) ans += a[i]; cout << ans << endl; }