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