import sys
import math

def insertion_sort(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 shell_sort(A, n):
	cnt = 0
	m = math.floor(math.log(2 * n + 1) / math.log(3))
	print(m)

	G = [0 for i in range(m)]	
	G[0] = 1
	for i in range(1, m):
		G[i] = 3 * G[i - 1] + 1

	G.reverse()
	print(G[0], end = "")
	for i in range(1, m):
		print(" " + str(G[i]), end = "")

	print("")
	for i in range(m):
		cnt += insertion_sort(A, n, G[i])

	print(cnt)
	
	for i in range(n):
		print(A[i])


#fin = open("test.txt", "r")
fin = sys.stdin

n = int(fin.readline())
A = [0 for i in range(n)]

for i in range(n):
	A[i] = int(fin.readline())

shell_sort(A, n) import sys sys import math math def insertion_sort(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 insertion_sort 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 shell_sort(A, n):
	cnt = 0
	m = math.floor(math.log(2 * n + 1) / math.log(3))
	print(m)

	G = [0 for i in range(m)]	
	G[0] = 1
	for i in range(1, m):
		G[i] = 3 * G[i - 1] + 1

	G.reverse()
	print(G[0], end = "")
	for i in range(1, m):
		print(" " + str(G[i]), end = "")

	print("")
	for i in range(m):
		cnt += insertion_sort(A, n, G[i])

	print(cnt)
	
	for i in range(n):
		print(A[i])


#fin = open("test.txt", "r") shell_sort cnt = 0 cnt 0 m = math.floor(math.log(2 * n + 1) / math.log(3)) m math.floor(math.log(2 * n + 1) / math.log(3)) math.floor math floor math.log(2 * n + 1) / math.log(3) math.log(2 * n + 1) math.log math log 2 * n + 1 2 * n 2 n 1 math.log(3) math.log math log 3 print(m) print m 0 for i in range(m) for i in range(m) i range(m) range m for i in range(m) 0 G = [0 for i in range(m)] G [0 for i in range(m)] G[0] = 1 G[0] G 0 1 for i in range(1, m):
		G[i] = 3 * G[i - 1] + 1

	 i range(1, m) range 1 m G[i] = 3 * G[i - 1] + 1 G[i] G i 3 * G[i - 1] + 1 3 * G[i - 1] 3 G[i - 1] G i - 1 i 1 1 G.reverse() G.reverse G reverse print(G[0], end = "") print G[0] G 0 end = "" end "" for i in range(1, m):
		print(" " + str(G[i]), end = "")

	 i range(1, m) range 1 m print(" " + str(G[i]), end = "") print " " + str(G[i]) " " str(G[i]) str G[i] G i end = "" end "" print("") print "" for i in range(m):
		cnt += insertion_sort(A, n, G[i])

	 i range(m) range m cnt += insertion_sort(A, n, G[i]) cnt insertion_sort(A, n, G[i]) insertion_sort A n G[i] G i print(cnt) print cnt for i in range(n):
		print(A[i])


#fin = open("test.txt", "r") i range(n) range n print(A[i]) print A[i] A i A A n n fin = sys.stdin fin sys.stdin sys stdin n = int(fin.readline()) n int(fin.readline()) int fin.readline() fin.readline fin readline 0 for i in range(n) for i in range(n) i range(n) range n for i in range(n) 0 A = [0 for i in range(n)] A [0 for i in range(n)] for i in range(n):
	A[i] = int(fin.readline()) i range(n) range n A[i] = int(fin.readline()) A[i] A i int(fin.readline()) int fin.readline() fin.readline fin readline shell_sort(A, n) shell_sort A n def insertion_sort(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 insertion_sort(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 insertion_sort fin = sys.stdin sys.stdin fin n = int(fin.readline()) int(fin.readline()) n A = [0 for i in range(n)] [0 for i in range(n)] A def shell_sort(A, n):
	cnt = 0
	m = math.floor(math.log(2 * n + 1) / math.log(3))
	print(m)

	G = [0 for i in range(m)]	
	G[0] = 1
	for i in range(1, m):
		G[i] = 3 * G[i - 1] + 1

	G.reverse()
	print(G[0], end = "")
	for i in range(1, m):
		print(" " + str(G[i]), end = "")

	print("")
	for i in range(m):
		cnt += insertion_sort(A, n, G[i])

	print(cnt)
	
	for i in range(n):
		print(A[i])


#fin = open("test.txt", "r") def shell_sort(A, n):
	cnt = 0
	m = math.floor(math.log(2 * n + 1) / math.log(3))
	print(m)

	G = [0 for i in range(m)]	
	G[0] = 1
	for i in range(1, m):
		G[i] = 3 * G[i - 1] + 1

	G.reverse()
	print(G[0], end = "")
	for i in range(1, m):
		print(" " + str(G[i]), end = "")

	print("")
	for i in range(m):
		cnt += insertion_sort(A, n, G[i])

	print(cnt)
	
	for i in range(n):
		print(A[i])


#fin = open("test.txt", "r") shell_sort
import sys
import math

def insertion_sort(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 shell_sort(A, n):
	cnt = 0
	m = math.floor(math.log(2 * n + 1) / math.log(3))
	print(m)

	G = [0 for i in range(m)]	
	G[0] = 1
	for i in range(1, m):
		G[i] = 3 * G[i - 1] + 1

	G.reverse()
	print(G[0], end = "")
	for i in range(1, m):
		print(" " + str(G[i]), end = "")

	print("")
	for i in range(m):
		cnt += insertion_sort(A, n, G[i])

	print(cnt)
	
	for i in range(n):
		print(A[i])


#fin = open("test.txt", "r")
fin = sys.stdin

n = int(fin.readline())
A = [0 for i in range(n)]

for i in range(n):
	A[i] = int(fin.readline())

shell_sort(A, n)