program main implicit none integer::N,k,i integer,allocatable::a(:) read *,N allocate(a(N)) read *,a if(N.eq.1) then print '("1")' return endif k = 1 do i=2,N if(a(1).lt.a(i)) then k = k + 1 end if a(i) = k end do a(1) = 1 call aprinter(a) contains subroutine aprinter(array) integer*4::array(:) character*32::cformat='(i0, (/,i0),i0)' write(cformat(5:9),'(i0)'),size(array)-1 write(*,cformat) array end subroutine aprinter end program main