program main
  implicit none
  integer :: N
  integer :: nin
  integer,allocatable :: B(:)
  integer,allocatable :: B1(:),B2(:)
  integer,allocatable :: out(:)
  logical :: lmiss
  integer :: i,j
  read(*,*) N
  allocate(B(N))
  read(*,*) B
  allocate(out(N))
  out=-1
  !
  ! search same num
  allocate(B1(N))
  B1=B
  do j = 0,N-1
     Nin = N-j
     allocate(B2(Nin))
     B2 = B1
     lmiss=.true.
     do i = Nin,1,-1
        if ( B2(i) ==i  ) then ! remove
           deallocate(B1)
           allocate(B1(Nin-1))
           B1(1:i-1) = B2(1:i-1)
           B1(i:Nin-1) = B2(i+1:Nin)
           out(N-j) = i
           lmiss = .false.
           exit
        end if
     end do
     if (lmiss) then
        write(*,'(i0)') -1
        stop
     end if
     deallocate(B2)
  end do
  do i = 1,N
     write(*,'(i0)') out(i)
  end do
  deallocate(B)
  stop
end program main