program main implicit none integer::N,i integer,allocatable::L(:),S(:) integer::indx(6),max read *,N allocate(L(N),S(N)) read *,L S = qsort(L) do i=1,6 indx(i) = COUNT(S.eq.i) end do max = MAXVAL(indx) do i=6,1,-1 if(indx(i).eq.max) then print '(i0)', i return end if end do contains recursive function qsort(x) result(y) integer,intent(in) ::x(:) integer,allocatable::y(:) integer::pivot,total total = size(x) if (total <=1) then y = x else pivot = x(total/2) y = [qsort(pack(x, x .lt. pivot)), & pack(x, x .eq. pivot), & qsort(pack(x, x .gt. pivot))] endif end function qsort end program main