#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, c = 0, k, a, t;
  cin >> n >> k;
  t = n;
  vector<int> v;
  while (t--) {
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  for (i = n - 1; i >= n - k; i--) c += v[i];
  cout << c;
}
