module Main where import Data.List (sortBy) data Input = Input { m :: Int , x :: Int , y :: Int , a :: [Int] } type Output = Maybe Int parse :: String -> Input parse s = let [_, m, x, y] = map read . words . head $ lines s a = map read . words . (!! 1) $ lines s in Input m x y a solve :: Input -> Output solve input = let a' = sortBy (flip compare) $ a input cond = (<= m input) . length . takeWhile (>= x input) $ a' in if cond then Just . sum . filter (> y input) . take (m input) $ a' else Nothing render :: Output -> String render Nothing = "Handicapped" render (Just x) = show x main :: IO () main = interact ( render . solve . parse )