#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,K,sum;
  sum = 0;
  cin >> N >> K;
vector<int> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
}
sort(vec.begin(), vec.end());
for (int i = 0; i < K; i++){
  sum += vec.at(N-1);
  N --;
}
  cout << sum << endl;
  
}
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
using namespace std;

int main(void) {
    double a,b; cin >> a >> b;
    int sum = 0;
    int i = 0;
    while (i < 2) {
        if (a > b) {
            sum += a;
            a--;
        } else {
            sum += b;
            b--;
        }
        i++;
    }
    cout << sum << endl;
}