#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6;
int n, k;
int v[MAX];
void solve() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v, v + n);
  long long ans = 0;
  for (int i = n - 1; k; i--) {
    ans += v[i];
    k--;
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
