program Limited_Insertion
    implicit none
    integer(4):: n, i, tar, ai
    integer(4), allocatable:: b(:), a(:)

    read*, n
    allocate(b(n), a(n))

    read*, b(:)
    ai=0

    do while (ai < n)
        tar = 0
        do i=1, n
            if (b(i) == i) tar = i
        end do

        if (tar == 0) then
            print*, -1
            stop
        end if

        ai=ai+1
        a(ai) = tar
        b(tar:n-1) = b(tar+1:n)
        b(n) = 0
    end do

    do i=n,1,-1
        print*, a(i)
    end do
end program Limited_Insertion