  n = gets(chomp:true).to_i
  array = gets(chomp:true).split.map(&:to_i)

  puts array.join(" ")

  for ope_index in 1...n

    cmp_index = ope_index - 1
    cmp_elem = array[cmp_index]
    pool_elem = array[ope_index]
    

      while cmp_index >= 0 && cmp_elem > pool_elem

        array[cmp_index + 1] = cmp_elem

        cmp_index -= 1
        cmp_elem = array[cmp_index]
      end

    array[cmp_index + 1] = pool_elem

    puts array.join(" ")

  end

