def insertionSort(arr, n)
    i = 1
    outputArr(arr,0)
    while i < n
        v = arr[i]
        j = i - 1
        while j >= 0 && v < arr[j] 
            arr[j+1] = arr[j]
            j -= 1
        end
        arr[j+1] = v
        i += 1
       
        if i == n
            outputArr(arr, 1)
        else 
            outputArr(arr,0)
        end
    end
    arr
end

def outputArr(arr, mode)
    str = ""
    arr.each do |i|
        str = str + i.to_s + " "
    end
    str = str.strip
    puts str
end

num = ARGF.gets.to_i
arr = ARGF.gets.split
arr = arr.map{|s| s.to_i}

insertionSort(arr, num)

