program main
implicit none
integer :: n
integer , allocatable :: b(:), c(:,:), res(:)
integer :: i, j

read(*,*) n
allocate(b(n))
allocate(c(n,n))
allocate(res(n))
read(*,*) b(1:n)


c(1,:) = b(:)
do i = 1, n
   if(b(i) > i ) then
      write(*,'(i0)') -1
      stop
   end if
   do j = i, n
      if(c(i,j) == j) then
         c(i+1, i:j-1) = c(i,i:j-1)
         c(i+1, j:n)   = c(i,j+1:n)
         res(i)        = j
      end if
   end do
end do

do i = 1 ,n
    write(*,'(i0)') res(n-i+1)
end do

end program main
