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

check = true

array.each_index {|i|
  if array[i] > i+1
    check = false
  end
}

if check == false
  puts -1
  exit
end

ans = []
while array.size != 0
  array.each_with_index.reverse_each do |num, i|
    # puts "#{num} // #{i}"
    if num == i+1
      ans.push(num)
      array.delete_at(i)
      break
    end
  end
end

puts ans.reverse
