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

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

if count == 1
  p -1
end
