n=gets.to_i
b=gets.split.map(&:to_i)
ans=[]

unless b.each_with_index.all?{|v,i|v<=i+1}
  puts -1
  exit
end

until b.empty?
  (b.size-1).downto(0){|i|
    if b[i]==i+1
      ans << b[i]
      b.delete_at i
      break
    end
  }
end
puts ans.reverse