#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, sum = 0;
  cin >> n >> k;
  int a[n];
  for (int &i : a) cin >> i;
  sort(a, a + n);
  while (k--) sum += a[k];
  cout << sum;
}
