N=gets.to_i
A=gets.split.map(&:to_i)
ans=[]
while !A.empty?
  target=(A.size-1).downto(0){|i| break i if A[i]==i+1}
  if A[target]!=target+1
    puts -1
    exit
  end
  A.delete_at(target)
  ans << target+1
end
puts ans.reverse