def insert_sort():
    n = int(input())
    A = [int(x) for x in input().split()]
    print(*A)
    for i in range(1,n):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(*A)



if __name__ == "__main__":
    insert_sort() def insert_sort():
    n = int(input())
    A = [int(x) for x in input().split()]
    print(*A)
    for i in range(1,n):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(*A) insert_sort n = int(input()) n int(input()) int input() input int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x A = [int(x) for x in input().split()] A [int(x) for x in input().split()] print(*A) print *A A for i in range(1,n):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(*A) i range(1,n) range 1 n v = A[i] v A[i] A i j = i - 1 j i - 1 i 1 while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
         j >= 0 and A[j] > v j >= 0 j 0 A[j] > v A[j] A j v A[j+1] = A[j] A[j+1] A j+1 j 1 A[j] A j j -= 1 j 1 A[j+1] = v A[j+1] A j+1 j 1 v print(*A) print *A A if __name__ == "__main__":
    insert_sort() __name__ == "__main__" __name__ "__main__" insert_sort() insert_sort def insert_sort():
    n = int(input())
    A = [int(x) for x in input().split()]
    print(*A)
    for i in range(1,n):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(*A) def insert_sort():
    n = int(input())
    A = [int(x) for x in input().split()]
    print(*A)
    for i in range(1,n):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(*A) insert_sort
def insert_sort():
    n = int(input())
    A = [int(x) for x in input().split()]
    print(*A)
    for i in range(1,n):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(*A)



if __name__ == "__main__":
    insert_sort()