import re
def insertionSort(A,n,g):
	cnt=0
	for i in range(g,n):
		v = A[i]
		j = i-g
		while(j>=0 and A[j]>v):
			A[j+g] = A[j]
			j = j-g
			cnt+=1
		A[j+g]=v
	return cnt

def shellSort(A,n):
	cnt=0
#	m=n//2
#	print(m)
#	G=[]
#	while(m>0):
#		G.append(m)
#		m//=2

	G=[]
	v=1
	c=1
	while(v<=n):
		G.append(v)
		v+=3**c
		c+=1
	G=list(reversed(G))
	m=len(G)
	print(m)

	print(re.sub("[\[\]\,]","",str(G)))
	for i in range(len(G)):
		cnt+=insertionSort(A,n,G[i])
	print(cnt)
		

n=int(input())
a=[]
for i in range(n):
	a.append(int(input()))

shellSort(a,n)

for i in range(len(a)):
	print(a[i]) import re re def insertionSort(A,n,g):
	cnt=0
	for i in range(g,n):
		v = A[i]
		j = i-g
		while(j>=0 and A[j]>v):
			A[j+g] = A[j]
			j = j-g
			cnt+=1
		A[j+g]=v
	return cnt insertionSort cnt=0 cnt 0 for i in range(g,n):
		v = A[i]
		j = i-g
		while(j>=0 and A[j]>v):
			A[j+g] = A[j]
			j = j-g
			cnt+=1
		A[j+g]=v
	 i range(g,n) range g n v = A[i] v A[i] A i j = i-g j i-g i g while(j>=0 and A[j]>v):
			A[j+g] = A[j]
			j = j-g
			cnt+=1
		 j>=0 and A[j]>v j>=0 j 0 A[j]>v A[j] A j v A[j+g] = A[j] A[j+g] A j+g j g A[j] A j j = j-g j j-g j g cnt+=1 cnt 1 A[j+g]=v A[j+g] A j+g j g v return cnt cnt A A n n g g def shellSort(A,n):
	cnt=0
#	m=n//2
#	print(m)
#	G=[]
#	while(m>0):
#		G.append(m)
#		m//=2

	G=[]
	v=1
	c=1
	while(v<=n):
		G.append(v)
		v+=3**c
		c+=1
	G=list(reversed(G))
	m=len(G)
	print(m)

	print(re.sub("[\[\]\,]","",str(G)))
	for i in range(len(G)):
		cnt+=insertionSort(A,n,G[i])
	print(cnt)
		 shellSort cnt=0 cnt 0 G=[] G [] v=1 v 1 c=1 c 1 while(v<=n):
		G.append(v)
		v+=3**c
		c+=1
	 v<=n v n G.append(v) G.append G append v v+=3**c v 3**c 3 c c+=1 c 1 G=list(reversed(G)) G list(reversed(G)) list reversed(G) reversed G m=len(G) m len(G) len G print(m) print m print(re.sub("[\[\]\,]","",str(G))) print re.sub("[\[\]\,]","",str(G)) re.sub re sub "[\[\]\,]" "" str(G) str G for i in range(len(G)):
		cnt+=insertionSort(A,n,G[i])
	 i range(len(G)) range len(G) len G cnt+=insertionSort(A,n,G[i]) cnt insertionSort(A,n,G[i]) insertionSort A n G[i] G i print(cnt) print cnt A A n n n=int(input()) n int(input()) int input() input a=[] a [] for i in range(n):
	a.append(int(input())) i range(n) range n a.append(int(input())) a.append a append int(input()) int input() input shellSort(a,n) shellSort a n for i in range(len(a)):
	print(a[i]) i range(len(a)) range len(a) len a print(a[i]) print a[i] a i n=int(input()) int(input()) n a=[] [] a def shellSort(A,n):
	cnt=0
#	m=n//2
#	print(m)
#	G=[]
#	while(m>0):
#		G.append(m)
#		m//=2

	G=[]
	v=1
	c=1
	while(v<=n):
		G.append(v)
		v+=3**c
		c+=1
	G=list(reversed(G))
	m=len(G)
	print(m)

	print(re.sub("[\[\]\,]","",str(G)))
	for i in range(len(G)):
		cnt+=insertionSort(A,n,G[i])
	print(cnt)
		 def shellSort(A,n):
	cnt=0
#	m=n//2
#	print(m)
#	G=[]
#	while(m>0):
#		G.append(m)
#		m//=2

	G=[]
	v=1
	c=1
	while(v<=n):
		G.append(v)
		v+=3**c
		c+=1
	G=list(reversed(G))
	m=len(G)
	print(m)

	print(re.sub("[\[\]\,]","",str(G)))
	for i in range(len(G)):
		cnt+=insertionSort(A,n,G[i])
	print(cnt)
		 shellSort def insertionSort(A,n,g):
	cnt=0
	for i in range(g,n):
		v = A[i]
		j = i-g
		while(j>=0 and A[j]>v):
			A[j+g] = A[j]
			j = j-g
			cnt+=1
		A[j+g]=v
	return cnt def insertionSort(A,n,g):
	cnt=0
	for i in range(g,n):
		v = A[i]
		j = i-g
		while(j>=0 and A[j]>v):
			A[j+g] = A[j]
			j = j-g
			cnt+=1
		A[j+g]=v
	return cnt insertionSort
import re
def insertionSort(A,n,g):
	cnt=0
	for i in range(g,n):
		v = A[i]
		j = i-g
		while(j>=0 and A[j]>v):
			A[j+g] = A[j]
			j = j-g
			cnt+=1
		A[j+g]=v
	return cnt

def shellSort(A,n):
	cnt=0
#	m=n//2
#	print(m)
#	G=[]
#	while(m>0):
#		G.append(m)
#		m//=2

	G=[]
	v=1
	c=1
	while(v<=n):
		G.append(v)
		v+=3**c
		c+=1
	G=list(reversed(G))
	m=len(G)
	print(m)

	print(re.sub("[\[\]\,]","",str(G)))
	for i in range(len(G)):
		cnt+=insertionSort(A,n,G[i])
	print(cnt)
		

n=int(input())
a=[]
for i in range(n):
	a.append(int(input()))

shellSort(a,n)

for i in range(len(a)):
	print(a[i])
