Problems
Insertion sort is a method that sorts an array by taking each element in order from the front, comparing it with the already sorted portion of the array, and inserting it into its correct position.
For example, given the sequence {5, 4, 3, 7, 6}, the insertion sort process is as follows:
Initially, the first value
5has nothing in front of it, so it is considered sorted.From the second element
4onward, each element is inserted into its correct position in the already sorted part.Note: In the third step,
7is larger than the previous sorted portion3 4 5, so it remains in its place.
Input
The first line contains the length of the sequence
The second line contains
Output
Excluding the initial state, print the sequence after each step of the insertion sort.
Example
5
5 4 3 7 6
4 5 3 7 6
3 4 5 7 6
3 4 5 7 6
3 4 5 6 7