def show (nums):

    for i in range(len(nums)):

        if i!=len(nums)-1:

            print(nums[i],end=' ')

        else :

            print(nums[i])

 

n=int(input())

nums=list(map(int,input().split()))

show(nums)

for i in range(1,n):

    v=nums[i]

    j=i-1

    while (j>=0 and nums[j]>v):

        nums[j+1]=nums[j]

        j-=1

    nums[j+1]=v

    show(nums)

N = int(eval(input()))

A_str = eval(input())

A = []

for s in A_str.split():

    A.append(int(s))



print((" ".join(map(str, A))))

for i in range(1, len(A)):

    key = A[i]

    j = i - 1

    while j >= 0 and A[j] > key:

        A[j + 1] = A[j]

        j -= 1

    A[j + 1] = key

    print((" ".join(map(str, A))))



def show(nums):
    for i in range(len(nums)):
        if i != len(nums) - 1:
            print(nums[i], end=" ")
        else:
            print(nums[i])


n = int(input())
nums = list(map(int, input().split()))
show(nums)
for i in range(1, n):
    v = nums[i]
    j = i - 1
    while j >= 0 and nums[j] > v:
        nums[j + 1] = nums[j]
        j -= 1
    nums[j + 1] = v
    show(nums)

N = int(eval(input()))
A_str = eval(input())
A = []
for s in A_str.split():
    A.append(int(s))
print((" ".join(map(str, A))))
for i in range(1, len(A)):
    key = A[i]
    j = i - 1
    while j >= 0 and A[j] > key:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = key
    print((" ".join(map(str, A))))

-def show(nums): -    for i in range(len(nums)): -        if i != len(nums) - 1: -            print(nums[i], end=" ") -        else: -            print(nums[i]) - - -n = int(input()) -nums = list(map(int, input().split())) -show(nums) -for i in range(1, n): -    v = nums[i] +N = int(eval(input())) +A_str = eval(input()) +A = [] +for s in A_str.split(): +    A.append(int(s)) +print((" ".join(map(str, A)))) +for i in range(1, len(A)): +    key = A[i] -    while j >= 0 and nums[j] > v: -        nums[j + 1] = nums[j] +    while j >= 0 and A[j] > key: +        A[j + 1] = A[j] -    nums[j + 1] = v -    show(nums) +    A[j + 1] = key +    print((" ".join(map(str, A))))