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

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

  do i = 1, n
    call remove(b, res(n - i + 1))
  end do

  do i = 1, n
    write (*, "(i0)") res(i)
  end do

  contains

  subroutine remove(b, ret)
    integer, allocatable, intent(inout) :: b(:)
    integer, intent(out) :: ret
    integer :: n, i, c(size(b))
    n = size(b)
    c = [(b(i) - i, i = 1, n)]
    loop: block
      do i = n, 1, -1
        if (c(i) == 0) exit loop
      end do
      write (*, "(i0)") -1
      stop
    end block loop
    ret = b(i)
    b = [b(:i - 1), b(i + 1:)]
  end subroutine remove
end program main
