let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
process.stdin.on('end', function() {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    inputString.shift();
    shellSort(inputString.map(v => Number(v)));
});

let count = 0;

const shellSort = (arr) => {
  const G = [];

  let g = 1;
  while (true) {
    if (g > arr.length) break;
    G.push(g);
    g = 3*g + 1;
  }

  console.log(G.length);

  const used = [];

  for (let i=G.length-1; i>=0; i--) {
    used.push(G[i]);
    insertionSort(arr, G[i]);
  }

  console.log(used.join(' '));
  console.log(count);
  console.log(arr.join(' '));
};

const insertionSort = (arr, g) => {
  for (let i=g; i<arr.length; i++) {
    const v = arr[i];
    let j = i - g;
    while (j>=0 && arr[j] > v) {
      arr[j+g] = arr[j];
      j = j - g;
      count++;
    }
    arr[j+g] = v;
  }
};



