#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	int k,n,l[60],sum=0,i;
	cin>>n>>k;
	for(i=0;i<n;i++){
		cin>>l[i];
	}
	sort(l, l + n, greater<int>());
	for(i=0;i<k;i++){
		sum+=l[i];
	}
	cout<<sum<<endl;
}
