n=gets.to_i
b=gets.split.map &:to_i

res=[]

until b.empty?
	f=false
	(b.size-1).downto(0){|i|
		if i+1==b[i]
			res<<b[i]
			b.delete_at(i)
			f = true
			break
		end
	}
	if !f && !b.empty?
		puts -1
		exit
	end
end

puts res.reverse