let () =
  let n, k = Scanf.scanf "%d %d" (fun n k -> n, k) in
  let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  Array.sort (fun x y -> y - x) a;
  Array.sub a 0 k |> Array.fold_left (+) 0
  |> Printf.printf "%d\n"
