//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

A = require('fs').readFileSync(config.input, 'ascii')
  .trim()
  .split(config.newline)
  .map(Number);
A.shift();

res = shellSort(A);
console.log(res.G.length);
console.log(res.G.join(' '));
console.log(res.cnt);
console.log(A.join('\n'));

function insertionSort(A, g) {
  var cnt, i, v, j;
  cnt = 0;
  for (i = g; i < A.length; i++) {
    console.log(A);
    v = A[i];
    j = i - g;
    while (j >= 0 && A[j] > v) {
      A[j + g] = A[j];
      j = j - g;
      cnt++;
    }
    A[j + g] = v;
  }
  return cnt;
}

function shellSort(A) {
  var cnt, G, i;
  cnt = 0;
  G = [];
  for (i = 1; i < A.length; i *= 2) G.push(i);
  G.reverse();
  for (i in G) cnt += insertionSort(A, G[i]);
  return {'G': G, 'cnt': cnt};
}