program answer
  implicit none
  integer :: i, j, N, m, a
  character(len=10), allocatable :: S(:), k(:)
  character(len=10) :: temp
  integer, allocatable :: count(:)

  read(*,*) N
  allocate(S(N))
  allocate(count(N))
  count=0
  
  do i = 1, N
     read(*,*) S(i)
     if(i==1) then
        count(i)=count(i)+1
     else
        do j =1, i-1
           if(S(i)==S(j)) then
              count(j)=count(j)+1
           end if
        end do
        count(i)=count(i)+1
     end if
  end do

  m=0
  do i = 1, N
     if(count(i)==maxval(count)) then
        m=m+1
        a=i
     end if
  end do

  if(m==1) then
     write(*,*) S(a)
     stop
  end if
  allocate(k(m))

  j=1
  do i = 1, N
     if(count(i)==maxval(count)) then
        k(j)=S(i)
        j=j+1
     end if
  end do

  !sort
  !do i = 1, m-1
  !   do j = i+1, m
  !      if(k(i)>k(j)) then
  !         temp=k(i)
  !         k(i)=k(j)
  !         k(j)=temp
  !      end if
  !   end do
  !end do

  call heapsort(m,k)
  do i = 1, m
     write(*,*) k(i)
  end do

  deallocate(S,k)
  stop
  contains

  subroutine heapsort(n,array)
  implicit none
  integer, intent(in) :: n
  character(len=10) :: array(1:n)
 
  integer ::i,g,j,l
  character(len=10) :: t

  if(n.le.0)then
     write(6,*)"Error, at heapsort"; stop
  endif

  l=n/2+1
  g=n
  do while(g.ne.1)
     if(l.gt.1)then
        l=l-1
        t=array(L)
     else
        t=array(g)
        array(g)=array(1)
        g=g-1
        if(g.eq.1) then
           array(1)=t
           exit
        end if
     end if
     i=l
     j=l+l
     do while(j.le.g)
        if(j.lt.g)then
           if(array(j).lt.array(j+1)) then
              j=j+1
           end if
        endif
        if (t.lt.array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=g+1
        end if
     end do
     array(i)=t
  end do

  return
end subroutine heapsort

 end program answer