#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[100000],n,m,s,i;
    cin>>n>>m;
    for(i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(i=n;i>=n-m+1;i--)
        s+=a[i];
    cout<<s;
    return 0;
}