N,*bs=$<.read.split.map(&:to_i)

count = 1
arr = Array.new(N,0)
N.times do |i|
  t = count
  j = N-1
  while 0 <= j
    if arr[j] == 0 && bs[j] == t
      arr[j] = 1
      count += 1
      p bs[j]
      break
    end
    t -= arr[j]
    j -= 1
  end
  if j < 0
    p -1
    exit 0
  end
end
