
N = gets.to_i
array = gets.split.map(&:to_i)
N.times do |n|    
	print("#{array[n]}")
	if n<N-1
		print(" ")
	end
end
print("\n")

1.upto(N-1) do |i|
	v = array[i]
	j = i-1
	while j >= 0 && array[j]>v
		array[j+1] = array[j]
		j-=1
		array[j+1] = v
	end
	N.times do |n|    
	print("#{array[n]}")
	if n<N-1
		print(" ")
	end
end
print("\n")
end