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

int insertion_sort(int,int[],int,int);
int shellSort(int,int[]);
void printArray(int[],int);
int main(int argc, char** argv) {
    int size;
    scanf("%d\n", &size);
    int array[size];
    for(int i = 0; i < size; i++)
        scanf("%d", &array[i]);
    
    int count = shellSort(size,array);
    printf("%d\n", count);
    printArray(array,size);
    
    return (EXIT_SUCCESS);
}

int insertion_sort(int size, int array[size], int gap, int count){
    int temp, j;
    for(int i = gap; i < size; i++){
        temp = array[i];
        j = i - gap;
        while(j >= 0 && array[j] > temp){
            array[j+gap] = array[j];
            j -= gap;
            if(j != 0) count++;
        }
        array[j+gap] = temp;
    }
    return count;
}

int shellSort(int size, int array[size]){
    int count = 0;
    int gap[8] = {701, 301, 132, 57, 23, 10, 4, 1}; //Ciura's Gap sequence
    for(int i = 0; i < 8; i++){
        if(size > gap[i]){
            if(count == 0){
                printf("%d\n", 8-i);
            }
            count = insertion_sort(size, array, gap[i], count);
            if(i != 7)
                printf("%d ", gap[i]);
            else
                printf("%d\n", gap[i]);
        }
    }
    return count;
}

void printArray(int array[], int count){
    for(int i = 0; i < count; i++){
        printf("%d\n", array[i]);
    }
}

