#include<stdio.h>
#include<math.h>

int main(void) {
	long int n, i, i1, j, cnt = 0, v, m, G[100];
	long long int A[1000000];
	/*??´??°n???????????????*/
	scanf("%d",&n);
	for (i = 0; i < n; i++)
		scanf("%d", &A[i]);
	/*shellSort*/
	m = cbrt(n);
	G[0] = 1;
	for (i = 0; i < m; i++)
		G[i + 1] = G[i]+3*G[i]*G[i];
	for (i1 = 0; i1 < m; i1++){
		/*insertionSort*/
		for (i = G[i1]; i < n; i++) {
			v = A[i];
			j = i - G[i1];
			while (j >= 0 && A[j]>v) {
				A[j + G[i1]] = A[j];
				j = j - G[i1];
				cnt++;
			}
			A[j + G[i1]] = v;
		}
	}
	/*??????*/
	printf("%d\n", m);
	for (i = 0; i < m; i++)
		printf("%d", G[i],i=m-1?' ':'\n');
	for (i = 0; i < n; i++)
		printf("%d", A[i], i = n - 1 ? ' ' : '\n');
}