n = gets.chomp.to_i
n -= 1
nums = gets.chomp.split.map(&:to_i)

nums.each_with_index do |val, idx|
      if idx == n
         printf "#{val}\n"
      else
         print "#{val} "
      end
end

for i in 1..n do

   k = i - 1

   while k >= 0

      unless nums[i-1] <= nums[i]
         temp = nums[i]
         nums[i] = nums[i-1]
         nums[i-1] = temp
      end

      i -= 1
      k -= 1

   end

   nums.each_with_index do |val, idx|
      if idx == n
         printf "#{val}\n"
      else
         print "#{val} "
      end
   end

end