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):
	global cnt
	cnt = 0
	G = []
	h = 1
	while h<=len(A):
		G.append(h)
		h = 3*h+1
	G.reverse()
	m = len(G)
	print(m)
	print(' '.join(map(str, G)))
	for g in G:
		insertion_sort(A, N, g)
	return m, G


N = int(input())
A = [int(input()) for i in range(N)]

shell_sort(A, N)
print(cnt)
for a in A:
	print(a)
 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
			A[j+g] = v 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):
	global cnt
	cnt = 0
	G = []
	h = 1
	while h<=len(A):
		G.append(h)
		h = 3*h+1
	G.reverse()
	m = len(G)
	print(m)
	print(' '.join(map(str, G)))
	for g in G:
		insertion_sort(A, N, g)
	return m, G shell_sort global cnt cnt = 0 cnt 0 G = [] G [] h = 1 h 1 while h<=len(A):
		G.append(h)
		h = 3*h+1
	 h<=len(A) h len(A) len A G.append(h) G.append G append h h = 3*h+1 h 3*h+1 3*h 3 h 1 G.reverse() G.reverse G reverse m = len(G) m len(G) len G print(m) print m print(' '.join(map(str, G))) print ' '.join(map(str, G)) ' '.join ' ' join map(str, G) map str G for g in G:
		insertion_sort(A, N, g)
	 g G insertion_sort(A, N, g) insertion_sort A N g return m, G return m, G m G A A N N 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 A = [int(input()) for i in range(N)] A [int(input()) for i in range(N)] shell_sort(A, N) shell_sort A N print(cnt) print cnt for a in A:
	print(a) a A print(a) print a N = int(input()) int(input()) N 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 A = [int(input()) for i in range(N)] [int(input()) for i in range(N)] A def shell_sort(A, N):
	global cnt
	cnt = 0
	G = []
	h = 1
	while h<=len(A):
		G.append(h)
		h = 3*h+1
	G.reverse()
	m = len(G)
	print(m)
	print(' '.join(map(str, G)))
	for g in G:
		insertion_sort(A, N, g)
	return m, G def shell_sort(A, N):
	global cnt
	cnt = 0
	G = []
	h = 1
	while h<=len(A):
		G.append(h)
		h = 3*h+1
	G.reverse()
	m = len(G)
	print(m)
	print(' '.join(map(str, G)))
	for g in G:
		insertion_sort(A, N, g)
	return m, G shell_sort
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):
	global cnt
	cnt = 0
	G = []
	h = 1
	while h<=len(A):
		G.append(h)
		h = 3*h+1
	G.reverse()
	m = len(G)
	print(m)
	print(' '.join(map(str, G)))
	for g in G:
		insertion_sort(A, N, g)
	return m, G


N = int(input())
A = [int(input()) for i in range(N)]

shell_sort(A, N)
print(cnt)
for a in A:
	print(a)

