11939 - Insertion sort   

Description

Please implement insertion sort algorithm to sort a sequence of number in ascending order, and show the sequence of number after each insert phase.

 

insertion sort (wiki): https://en.wikipedia.org/wiki/Insertion_sort

Input

There are 2 lines input.

The first line contains a integer n, indicating the total number of integers would be sorted. (n <= 1000)

The second line consists of the integers being sorted.

Output

Show the sequence of number after each insert phase.

If the input has n numbers, the output would have n-1 lines.

note: print a space before each number, and print '\n' in the end of each line.

Sample Input  Download

Sample Output  Download

Tags




Discuss