import copy 
N = int(input())
#*L, = map(str, input().split())
L = [int(input()) for i in range(N)]
#*L, = input().split()

#A1 = copy.copy(L)
#A2 = copy.copy(L)
#G = []
G = []
cnt = 0

def insertion_sort(A,n,g):
	global cnt
	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


def shell_sort(A,n):
	h = 1
	while True:
		if h > n:
			break
		G.append(h)
		h = 3*h + 1
		
	for i in reversed(range(len(G))):
		insertion_sort(A,n,G[i])

shell_sort(L,N)
print(len(G))
G = G[::-1]
print(*G)
print(cnt)
for i in L:
	print(i)



 import copy copy N = int(input()) N int(input()) int input() input int(input()) for i in range(N) for i in range(N) i range(N) range N for i in range(N) int(input()) int input() input L = [int(input()) for i in range(N)] L [int(input()) for i in range(N)] G = [] G [] cnt = 0 cnt 0 def insertion_sort(A,n,g):
	global cnt
	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 insertion_sort global cnt 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 A A n n g g def shell_sort(A,n):
	h = 1
	while True:
		if h > n:
			break
		G.append(h)
		h = 3*h + 1
		
	for i in reversed(range(len(G))):
		insertion_sort(A,n,G[i]) shell_sort h = 1 h 1 while True:
		if h > n:
			break
		G.append(h)
		h = 3*h + 1
		
	 True if h > n:
			break
		 h > n h n break G.append(h) G.append G append h h = 3*h + 1 h 3*h + 1 3*h 3 h 1 for i in reversed(range(len(G))):
		insertion_sort(A,n,G[i]) i reversed(range(len(G))) reversed range(len(G)) range len(G) len G insertion_sort(A,n,G[i]) insertion_sort A n G[i] G i A A n n shell_sort(L,N) shell_sort L N print(len(G)) print len(G) len G G = G[::-1] G G[::-1] G ::-1 -1 print(*G) print *G G print(cnt) print cnt for i in L:
	print(i) i L print(i) print i cnt = 0 0 cnt def shell_sort(A,n):
	h = 1
	while True:
		if h > n:
			break
		G.append(h)
		h = 3*h + 1
		
	for i in reversed(range(len(G))):
		insertion_sort(A,n,G[i]) def shell_sort(A,n):
	h = 1
	while True:
		if h > n:
			break
		G.append(h)
		h = 3*h + 1
		
	for i in reversed(range(len(G))):
		insertion_sort(A,n,G[i]) shell_sort N = int(input()) int(input()) N L = [int(input()) for i in range(N)] [int(input()) for i in range(N)] L G = G[::-1] G[::-1] G G = [] [] G def insertion_sort(A,n,g):
	global cnt
	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 def insertion_sort(A,n,g):
	global cnt
	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 insertion_sort
import copy 
N = int(input())
#*L, = map(str, input().split())
L = [int(input()) for i in range(N)]
#*L, = input().split()

#A1 = copy.copy(L)
#A2 = copy.copy(L)
#G = []
G = []
cnt = 0

def insertion_sort(A,n,g):
	global cnt
	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


def shell_sort(A,n):
	h = 1
	while True:
		if h > n:
			break
		G.append(h)
		h = 3*h + 1
		
	for i in reversed(range(len(G))):
		insertion_sort(A,n,G[i])

shell_sort(L,N)
print(len(G))
G = G[::-1]
print(*G)
print(cnt)
for i in L:
	print(i)




