import Control.Applicative import Data.List import Data.Monoid main = do _ <- getLine ls <- map read . words <$> getLine :: IO [Int] let cmp x y = (length y `compare` length x) `mappend` (head y `compare` head x) l = head . head . sortBy cmp . group . sort $ ls in print l