program speedrun
    implicit none
    integer::N
    character(10),allocatable,dimension(:)::S
    integer,allocatable,dimension(:)::Votecnt
    integer::i
    integer::maxnum,cnt,cnting
    read*,N
    allocate(S(N))
    do i=1,N
        read*,S(i)
    end do
    call heapsort(N,S)
    
    allocate(Votecnt(N))
    Votecnt=0
    maxnum=0
    cnt=0;cnting=1
    do i=1,N
        if(S(cnting)==S(i))then
            cnt=cnt+1
        else
            Votecnt(cnting)=cnt
            maxnum=max(maxnum,cnt)
            cnting=i;cnt=1
        endif
    end do
    Votecnt(cnting)=cnt
    maxnum=max(maxnum,cnt)
    do i=1,N
        if(Votecnt(i)==maxnum)then
            print"(A)",trim(S(i))
        endif
    enddo
contains
subroutine heapsort(n,array)
  implicit none
!ここの入力は状況に応じて変更すること
  integer,intent(in) :: n
  character(10),intent(inout) :: array(1:n)
  integer::i,k,j,l
  character(10):: t

  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j<=k)
        if(j < k)then
           if(array(j) < array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo
  return
end subroutine heapsort

end program speedrun