N = gets.to_i
B = gets.chomp.split.map(&:to_i)

ans = []
found = false
N.times do |i|
  found = false
  (B.length - 1).downto(0) do |i|
    if B[i] == i + 1
      found = true
      ans.unshift(B.delete_at(i))
      break
    end
  end
  break if not found
end

if found
  ans.each do |item|
    puts item
  end
else
  puts -1
end