N = gets.to_i
B = gets.split.map(&:to_i)

list = []
ans = []
hash = Hash.new {|h, k| h[k] = [] }

B.each_with_index do |b, i|
  hash[b] << i
end

if B.first > 1
  puts -1
  exit
end

list << hash[B.first].shift
ans << 1

B[1..-1].each.with_index(2) do |b, i|
  if i < b
    puts -1
    exit
  end

  n = hash[b].first

  idx = list.bsearch_index { |x| x >= n } || i - 1

  list.insert(idx, hash[b].shift)
  ans << idx
end

puts ans
