def insertionSort(n, a)
  n.times do |i|
    v, j = a[i], i - 1
    while j >= 0 && a[j] > v
      a[j + 1] = a[j]
      j -= 1
      a[j + 1] = v
    end
    puts a.join(' ')
  end
end
insertionSort(gets.to_i, gets.split.map(&:to_i))