def insertionSort(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 = cnt + 1
		A[j + g] = v

def shellSort(A, n):
	global m
	global G

	h = 1
	while (True):
		if h > n:
			break
		G.append(h)
		h = 3 * h + 1

	m = len(G)
	G.reverse()

	for i in range(m):
		insertionSort(A, n, G[i])

if __name__ == '__main__':
	N = int(input())
	R = [int(input()) for i in range(N)]

	cnt = 0
	G = []
	m = 0

	shellSort(R, N)

	print(m)
	print(" ".join(map(str, G)))
	print(cnt)
	for i in range(N):
		print(R[i]) def insertionSort(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 = cnt + 1
		A[j + g] = v insertionSort 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 = 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 = 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 = cnt + 1 cnt cnt + 1 cnt 1 A[j + g] = v A[j + g] A j + g j g v A A n n g g def shellSort(A, n):
	global m
	global G

	h = 1
	while (True):
		if h > n:
			break
		G.append(h)
		h = 3 * h + 1

	m = len(G)
	G.reverse()

	for i in range(m):
		insertionSort(A, n, G[i]) shellSort global m global G 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 m = len(G) m len(G) len G G.reverse() G.reverse G reverse for i in range(m):
		insertionSort(A, n, G[i]) i range(m) range m insertionSort(A, n, G[i]) insertionSort A n G[i] G i A A n n if __name__ == '__main__':
	N = int(input())
	R = [int(input()) for i in range(N)]

	cnt = 0
	G = []
	m = 0

	shellSort(R, N)

	print(m)
	print(" ".join(map(str, G)))
	print(cnt)
	for i in range(N):
		print(R[i]) __name__ == '__main__' __name__ '__main__' 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 R = [int(input()) for i in range(N)] R [int(input()) for i in range(N)] cnt = 0 cnt 0 G = [] G [] m = 0 m 0 shellSort(R, N) shellSort R N print(m) print m print(" ".join(map(str, G))) print " ".join(map(str, G)) " ".join " " join map(str, G) map str G print(cnt) print cnt for i in range(N):
		print(R[i]) i range(N) range N print(R[i]) print R[i] R i def insertionSort(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 = cnt + 1
		A[j + g] = v def insertionSort(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 = cnt + 1
		A[j + g] = v insertionSort def shellSort(A, n):
	global m
	global G

	h = 1
	while (True):
		if h > n:
			break
		G.append(h)
		h = 3 * h + 1

	m = len(G)
	G.reverse()

	for i in range(m):
		insertionSort(A, n, G[i]) def shellSort(A, n):
	global m
	global G

	h = 1
	while (True):
		if h > n:
			break
		G.append(h)
		h = 3 * h + 1

	m = len(G)
	G.reverse()

	for i in range(m):
		insertionSort(A, n, G[i]) shellSort N = int(input()) int(input()) N cnt = 0 0 cnt G = [] [] G m = 0 0 m R = [int(input()) for i in range(N)] [int(input()) for i in range(N)] R
def insertionSort(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 = cnt + 1
		A[j + g] = v

def shellSort(A, n):
	global m
	global G

	h = 1
	while (True):
		if h > n:
			break
		G.append(h)
		h = 3 * h + 1

	m = len(G)
	G.reverse()

	for i in range(m):
		insertionSort(A, n, G[i])

if __name__ == '__main__':
	N = int(input())
	R = [int(input()) for i in range(N)]

	cnt = 0
	G = []
	m = 0

	shellSort(R, N)

	print(m)
	print(" ".join(map(str, G)))
	print(cnt)
	for i in range(N):
		print(R[i])