import std.stdio, std.string, std.array, std.conv;

void insertionSort(int n, int[] x) {
    foreach (i; 1 .. n) {
        int v = x[i];
        int j = i - 1;
        while (j >= 0 && x[j] > v) {
            x[j+1] = x[j];
            --j;
        }
        x[j+1] = v;
        foreach (k, y; x) {
            y.write;
            if (k != n - 1) " ".write;
            else writeln;
        }
    }
}

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.chomp.split.to!(int[]);
    foreach (x; a) {
        x.write;
        if (x != a[n-1]) " ".write;
        else writeln;
    }
    insertionSort(n, a);
}
