N = gets.to_i
b = gets.split.map(&:to_i)

res = []

until b.empty? do
  (1..b.length).reverse_each do |i|
    if b[i-1] == i
      res << i
      b.delete_at(i-1)
      break
    end

    if i == b.length
      puts -1
      exit
    end
  end
end

puts res.reverse
