const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);
const list = line[1].split(' ').map(x => parseInt(x));

const sort = arr => {
    for (let i = 1; i < arr.length; i++) {
        const v = arr[i];
        j = i - 1;
        console.log(arr.map(x => x.toString()).join(' '));
        while (j >= 0 && arr[j] > v) {
            arr[j+1] = arr[j];
            j--;
        }
        arr[j+1] = v;
    }

    console.log(arr.map(x => x.toString()).join(' '));
    return arr;
};

sort(list);
