program main
  implicit none
  integer(8) i,N
  integer(8),allocatable :: A(:),score(:)
  read(*, *) N
  allocate(A(N))
  allocate(score(N))
  read(*, *) (A(i), i = 1,N)
  do i = 1,N
    score(i) = i + A(i)*10**6
  end do
  !write(*, *) score
  call qsort(score)
  do i = 1,N
    score(i) = mod(score(i),10**6)
  end do
  write(*, *) score

  
contains

recursive subroutine qsort(a)
implicit none
!integer(8),intent(in) :: n
integer(8),intent(inout) :: a(:)
integer(8)::i,j,toobig,toosmall,pv,n
n = size(a)
i = 1
j = n
pv = a((i+j)/2)
do
   do
     if (a(i) < pv) then
       i = i+1
     else
       exit
     end if
   end do
   do
     if(a(j) > pv) then
       j = j-1
     else
       exit
     end if
   end do
   if (i>=j) then
     exit
   else
     toobig = a(j)
     toosmall = a(i)
     a(i) = toobig
     a(j) = toosmall
     i = i+1
     j = j-1
   end if
 end do
 if (i > 2) then
   call qsort(a(1:i-1))
 end if
 if (j < n-1) then
   call qsort(a(j+1:n))
 end if
end subroutine qsort
end program main
