import Control.Applicative
import Data.List

qsort :: [Int] -> [Int]
qsort [] = []
qsort (p:xs) = qsort lt ++ [p] ++ qsort gteq
  where lt   = [x | x <- xs, x <  p]
        gteq = [x | x <- xs, x >= p]

modeValue :: [(Int, Int)] -> Int
modeValue xs = maximum $ map snd xs

findMax :: [(Int, Int)] -> Int -> [Int]
findMax [] _ = []
findMax xs m =
  let ys = filter (\y -> snd y == m) xs
  in
      map fst ys

reshape :: [Int] -> [(Int, Int)]
reshape [] = []
reshape (x:xs) =
  let ys = filter (\y -> x == y) xs
  in
      (x, 1 + length ys) : reshape (xs \\ ys)

solver :: [Int] -> [Int]
solver [] = []
solver xs =
  let ys  = reshape xs
      m   = modeValue ys
  in
      findMax ys m

main :: IO()
main = do
  contents <- map (read :: String -> Int) . lines <$> getContents
  mapM_ print $ qsort $ solver contents