#! /bin/ruby

n = gets.chomp.to_i
targets = gets.chomp.split(" ").map(&:to_i)

ans = []
n.times do |i|
  (n-i).downto(1) do |m|
    index = targets.index(m)
    if !index
      next
    end
    if targets[index] == index + 1
      ans << targets.delete_at(index)
      break
    end
  end
end
ans.reverse.each {|a| puts a }
