import Data.List(sortBy) main :: IO () main = do [_, k] <- f solve k <$> f >>= print where f = map read <$> words <$> getLine solve :: Int -> [Int] -> Int solve k = maximum . take k . scanl1 (+) . sortBy (flip compare)