#include <bits/stdc++.h>
using namespace std;



int main() {
int a,b,sum=0;
cin>>a>>b;
vector<int>v(a);
for(int i=0;i<a;i++)
cin>>v[i];
sort(v.begin() ,v.end());
for(int i=a-1;i>=a-b;i--){
sum+=v[i];
}
cout<<sum<<endl;
return 0;
}