#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, c, sum = 0;
  cout << "Enter the number of produce item" << endl;
  cin >> i >> c;
  int y[i];
  cout << "enter the product yen :" << endl;
  for (int j = 0; j < i; j++) {
    cin >> y[j];
  }
  for (int j = 0; j < i; j++) {
    for (int k = j + 1; k < i; k++) {
      if (y[j] < y[k]) {
        int tamp = y[j];
        y[j] = y[k];
        y[k] = tamp;
      }
    }
  }
  for (int j = i - 1; c > 0; j--) {
    sum = sum + y[j];
    c--;
  }
  cout << sum << endl;
}
