# AtCoder Grand Contest 032

URL: https://atcoder.jp/contests/agc032 (opens new window)

# A

n = gets.chomp.to_i
arr = gets.chomp.split(" ").map(&:to_i)

# 操作を逆にたどって空配列に戻せるかを確認する
operation = []
while arr.length > 0 do
  flag = true
  arr.length.downto(1) do |i|
    if arr[i - 1] == i
      operation << i
      arr.delete_at(i - 1)
      flag = false
      break
    end
  end
  if flag
    puts -1
    exit
  end
end

operation.reverse.each do |a|
  puts a
end
Last Updated: 2020/08/29 17:41