#include <stdio.h>
#include <stdlib.h>

#define INTERVALS_NUM 100

void dispNumsLn(int *nums, int length) 
{
    int i;

    for(i = 0; i < length; i++) {
        printf("%d\n", nums[i]);
    }
}

int insertionSort(int *nums, int length, int interval) 
{
    int i, j, target, cnt = 0;

    for(i = interval; i < length; i++) {
        j = i - interval;
        target = nums[i];

        while(j >= 0 && nums[j] > target) {
            nums[j + interval] = nums[j];
            j -= interval;
            cnt++;
        }
        nums[j + interval] = target;
    }
    return cnt;
}

int shellSort(int *nums, int length)
{
    int i, m, cnt = 0;
    int intervals[INTERVALS_NUM] = {40, 13, 4, 1};

    for(i = INTERVALS_NUM - 1; intervals[i] < length; i--);
    if(intervals[i] == length)
        m = INTERVALS_NUM - i;
    else
        m = INTERVALS_NUM - i - 1;

    printf("%d\n", m);
    for(i = INTERVALS_NUM - m; i < INTERVALS_NUM; i++)
        printf("%d ", intervals[i]);
    printf("\n");
    for(i = INTERVALS_NUM - m; i < INTERVALS_NUM; i++) {
        cnt += insertionSort(nums, length, intervals[i]);
    }

    return cnt;
}

int main(void) 
{
    int n, i, cnt;
    int *nums;

    scanf("%d", &n);
    nums = malloc(sizeof(int) * n);
    for(i = 0; i < n; i++) {
        scanf("%d", nums + i);
    }
    cnt = shellSort(nums, n);	
    printf("%d\n", cnt);
    dispNumsLn(nums, n);

    return 0;
}