function main(input) {
  const args = input.split("\n");
  insertionSort(args[1].split(" ").map(i => +i), args[0]);
}

function insertionSort(A, N) {
  console.log(A.join(" "));
  for (let i = 1; i < N; i++) {
    let v = A[i];
    let j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    console.log(A.join(" "));
  }
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));
