n = gets.to_i
a = gets.split.map(&:to_i)

ans = []
while a.size > 0
  (a.size - 1).downto(0) do |i|
    if a[i] == i + 1
      ans.unshift(a.delete_at(i))
      break
    end
    if i == 0
      puts -1
      exit
    end
  end
end

puts ans