def inseration_sort(a,n)
    a.each_with_index do |val,key|
          if key != a.size-1
            print val; print " "
          else
            print val; print "\n"
          end
     end
    1.upto(n-1) do |i|
        v = a[i]
        j = i-1
        while j >= 0 && v <= a[j]
            a[j+1] = a[j]
            a[j] = v
            j -= 1
        end
        a.each_with_index do |val,key|
          if key != a.size-1
            print val; print " "
          else
            print val; print "\n"
          end
        end
    end
end


n=gets.chomp.to_i
a=gets.chomp.split(" ").map{|i|i.to_i}

inseration_sort(a,n)
