
(def parse-input
  (fn [s]
    (mapv #(Integer/parseInt %) (clojure.string/split s #" "))))

(defn res [hs]
  (fn [k]
    (apply +' (drop k (sort > hs)))))

(def nk (parse-input (read-line)))
(def hs (parse-input (read-line)))

(def drop-hs-fn (res hs))
(println (drop-hs-fn (last nk)))