let _ =
    let [n; k] = List.map int_of_string (Str.split (Str.regexp " ") (read_line ())) in
    let ls = List.map int_of_string (Str.split (Str.regexp " ") (read_line ())) in
    let rec drop l = function 0 -> l | n -> drop (List.tl l) (n-1) in
    print_int (List.fold_left (+) 0 (drop (List.sort compare ls) (n-k)))