def check(n, b)
  return 0 if n == 0
  n.times do |k|
    if b[k] > k+1
      return -1
    end
  end
  0
end

def resolve(n, b)
  c = []
  return [1] if (n == 1 and b[0] == 1)
  if check(n, b)
    n.times do |k|
      b1 = []
      b.each { |x| b1.push x }
      if b1[k] == k+1
        b1.delete_at(k)
        c = resolve(n-1, b1)
        if (! c.empty?) # 解がある場合
          c.push b[k]
          break;
        end
      end
    end
  end
  c
end

n = readline.chop.to_i
b = readline.split(' ').map{|n| n.to_i}
c = resolve(n, b)
if c.empty?
  puts -1
else
  c.each do |x| puts x end
end