def limited_insertion
  n = 0
  b = []
  i = 0
  while line = gets
    n = line[0].to_i if i == 0
    b = line.split(' ').map{|v| v.to_i} if i == 1
    break if i == 1
    i += 1
  end

  a = []
  for i in 1..n
    result = -1
    for j in 1..i
      if b[i-1] == j
        result = j
        break
      end
    end

    p result

    break if result == -1
  end
end

limited_insertion