gets
b = gets.chomp.split(' ').map(&:to_i)
answer = []

while b.length > 0 do
  len = b.length
  (len- 1).downto(0) do |i|
    if b[i] == i + 1
      popped = b.delete_at(i)
      answer.unshift(popped)
      break
    end
  end
  break if len == b.length
end
if b.length > 0
  puts -1
else
  answer.each { |i| puts i }
end