n = gets.chomp.to_i
b = gets.split.map(&:to_i)
0.upto(n-1) do |i|
  if b[i] > i+1
    puts (-1)
    exit
  end
end
prev = 0
ans = []
s = []
b.reverse_each do |e|
  if e != 1
    s.push e
  else
    s.push e
    ans += s.sort
    s = []
  end
end
puts ans
