#include <bits/stdc++.h>
int main() {
  int all, buy, a, i, sum = 0, oki;
  int price[all];
  scanf("%d%d", &all, &buy);
  for (i = 0; i < all; i++) {
    scanf("%d", &price[i]);
  }
  a = 1;
  for (i = 0; i < buy; i++) {
    for (a = 0; a < all; a++) {
      if (price[i] > price[a]) {
        oki = price[i];
        price[i] = price[a];
        price[a] = oki;
      }
    }
  }
  for (i = 0; i < buy; i++) {
    sum = sum + price[i];
  }
  printf("%d", sum);
}
