defmodule Main do def main do IO.read(:line) IO.read(:line) |> String.trim() |> String.split() |> Enum.map(&String.to_integer/1) |> solve |> IO.puts() end def solve(l) do l |> extract |> decide end def extract(l) do extract_rec(l |> Enum.group_by(& &1) |> Map.to_list(), %{}, 0) end def extract_rec([], r, _) do r end def extract_rec([{k, v} | t], r, m) do cond do v |> length >= m -> extract_rec(t, r |> Map.put(k, v |> length), v |> length) true -> extract_rec(t, r, m) end end def decide(m) do n = m |> Map.values() |> Enum.max() m |> Map.to_list() |> Enum.filter(fn {_, v} -> v == n end) |> Enum.map(fn {k, _} -> k end) |> Enum.max() end end