module Main where import Data.List main :: IO () main = do { [n] <- getInts ; xs <- getInts ; print $ av $ snd3 $ foldl f ([],[],[]) xs } where f y x = case y of (ls,[m],rs) | x < m -> case insertBy (flip compare) x ls of l:ls' -> (ls',[l,m],rs) | otherwise -> case insert x rs of r:rs' -> (ls,[m,r],rs') (ls,[m,n],rs) | x < m -> (insertBy (flip compare) x ls,[m],n:rs) | x < n -> (m:ls,[x],n:rs) | otherwise -> (m:ls,[n],insert x rs) (_,[],_) -> ([],[x],[]) getInts :: IO [Int] getInts = map read . words <$> getLine snd3 :: (a,b,c) -> b snd3 (_,b,_) = b av :: [Int] -> Double av [x] = fromIntegral x av [x,y] = fromIntegral (x + y) / 2