#include <bits/stdc++.h>
int main() {
  int N;
  int K;
  scanf("%d%d", &N, &K);
  int str[N];
  int str2[N];
  int i;
  for (i = 0; i < N; i++) {
    scanf("%d", &str[i]);
    str2[i] = 0;
  }
  str[N] = '\0';
  for (int l = 0; l < N; l++) {
    str2[l] = str[l];
  }
  int j;
  int k;
  int tmp;
  for (j = 0; j < N; j++) {
    for (k = 0; k < N - 1; j++) {
      if (str2[k] < str2[k + 1]) {
        tmp = str2[k];
        str2[k] = str2[k - 1];
        str2[k - 1] = tmp;
      }
    }
  }
  int sum;
  for (int m = 0; m < k; m++) {
    sum += str2[m];
  }
  printf("%d", sum);
  return 0;
}
