
import std.algorithm,
       std.string,
       std.array,
       std.stdio,
       std.range,
       std.conv;

void main() {
  int[] NK = readln.chomp.split.to!(int[]);
  int N = NK[0],
      K = NK[1];
  int[] l = readln.chomp.split.to!(int[]);

  std.algorithm.sort!("a<b")(l).reverse;

  int A;

  foreach (i; 0..K) {
    A += l[i];
  }

  writeln(A);
}
