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

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

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


end program main
