#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  for (int i = 0; i < N; ++i) cin >> p[i];
  sort(p.rbegin(), p.rend());
  int res = 0;
  for (int i = 0; i < K; ++i) res += p[i];
  cout << res << endl;
  return 0;
}
