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