open Batteries
open BatPrintf

let scan fmt f =
  Scanf.sscanf (read_line ()) fmt f

let scan_list cnv =
  read_line ()
  |> String.split_on_char ' '
  |> List.map cnv

let scan_listn n cnv =
  (0 --^ n) /@ (fun _ -> (cnv % read_line) ())

let rec zip xs ys =
  match xs, ys with
  | [], _ -> []
  | _, [] -> []
  | x::xs, y::ys ->
    (x, y) :: zip xs ys

let n = scan "%d" identity
let s = scan_listn n identity

let () =
  let assoc =
    fold (fun assoc k -> List.modify_opt k
             (function
               | None -> Some 0
               | Some n -> Some (n + 1)) assoc) [] s in
  let m = List.fold_left (fun m x -> if m < (Tuple.Tuple2.second x) then (Tuple.Tuple2.second x) else m) 0 assoc in
  List.filter (fun x -> (Tuple.Tuple2.second x) = m ) assoc
  |> List.map Tuple.Tuple2.first
  |> List.sort String.compare
  |> String.concat "\n"
  |> printf "%s\n"
