open System let (N, K) = let t = Console.ReadLine().Split() |> Array.map int t.[0], t.[1] let A = Console.ReadLine().Split() |> Array.map int A |> Array.sortDescending |> Array.splitAt 1 |> fun (a, b) -> let t = b |> Array.truncate K |> Array.where(fun x -> x > 0) Array.fold(fun acc x -> acc + x) a.[0] t |> printfn "%i"