#include <iostream>
#include <algorithm>
using namespace std;
int a[100001];
long long sum=0;
int main(){
	int i,j,k,n;
	cin>>n>>k;
	for(i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	for(i=n;i>n-k;i--)sum+=a[i];
	cout<<sum<<endl;
	return 0;
}