def insertionSort(A):
	for i in range(1, len(A)):
		j = A[i]
		k = i
		while k - 1 >= 0:
			if A[k - 1] > j:
				A[k] = A[k - 1]
				A[k - 1] = j
			k = k - 1
	return A


def insertionSort(m, A, CNT):
	for i in range(m, len(A)):
		j = A[i]
		k = i
		while k - m >= 0 and A[k-m] > j:
			A[k] = A[k - m]
			A[k - m] = j
			CNT = CNT + 1
			k = k - m
#	while k - m >= 0:
#		if A[k - m] > j:
#			A[k] = A[k - m]
#			A[k - m] = j
#			CNT = CNT + 1
#		k = k - m
	return A, CNT


n = int(input())  # 例:6
a = []  # 例:[1, 4, 3, 6, 2, 5]
for i in range(0, n):
	a.append(int(input()))
cnt = 0

M = []
temp = 1
while temp <= n:
	M.append(temp)
	temp = 3 * temp + 1
M.sort(reverse=True)
#M=[1]
for j in M:
	a, cnt = insertionSort(j, a, cnt)

print(len(M))
print(' '.join([str(n) for n in M]))
print(cnt)
for k in a:
	print(k)
 def insertionSort(A):
	for i in range(1, len(A)):
		j = A[i]
		k = i
		while k - 1 >= 0:
			if A[k - 1] > j:
				A[k] = A[k - 1]
				A[k - 1] = j
			k = k - 1
	return A insertionSort for i in range(1, len(A)):
		j = A[i]
		k = i
		while k - 1 >= 0:
			if A[k - 1] > j:
				A[k] = A[k - 1]
				A[k - 1] = j
			k = k - 1
	 i range(1, len(A)) range 1 len(A) len A j = A[i] j A[i] A i k = i k i while k - 1 >= 0:
			if A[k - 1] > j:
				A[k] = A[k - 1]
				A[k - 1] = j
			k = k - 1
	 k - 1 >= 0 k - 1 k 1 0 if A[k - 1] > j:
				A[k] = A[k - 1]
				A[k - 1] = j
			 A[k - 1] > j A[k - 1] A k - 1 k 1 j A[k] = A[k - 1] A[k] A k A[k - 1] A k - 1 k 1 A[k - 1] = j A[k - 1] A k - 1 k 1 j k = k - 1 k k - 1 k 1 return A A A A def insertionSort(m, A, CNT):
	for i in range(m, len(A)):
		j = A[i]
		k = i
		while k - m >= 0 and A[k-m] > j:
			A[k] = A[k - m]
			A[k - m] = j
			CNT = CNT + 1
			k = k - m
#	while k - m >= 0:
#		if A[k - m] > j:
#			A[k] = A[k - m]
#			A[k - m] = j
#			CNT = CNT + 1
#		k = k - m
	return A, CNT insertionSort for i in range(m, len(A)):
		j = A[i]
		k = i
		while k - m >= 0 and A[k-m] > j:
			A[k] = A[k - m]
			A[k - m] = j
			CNT = CNT + 1
			k = k - m
#	while k - m >= 0:
#		if A[k - m] > j:
#			A[k] = A[k - m]
#			A[k - m] = j
#			CNT = CNT + 1
#		k = k - m
	 i range(m, len(A)) range m len(A) len A j = A[i] j A[i] A i k = i k i while k - m >= 0 and A[k-m] > j:
			A[k] = A[k - m]
			A[k - m] = j
			CNT = CNT + 1
			k = k - m
#	while k - m >= 0:
#		if A[k - m] > j:
#			A[k] = A[k - m]
#			A[k - m] = j
#			CNT = CNT + 1
#		k = k - m
	 k - m >= 0 and A[k-m] > j k - m >= 0 k - m k m 0 A[k-m] > j A[k-m] A k-m k m j A[k] = A[k - m] A[k] A k A[k - m] A k - m k m A[k - m] = j A[k - m] A k - m k m j CNT = CNT + 1 CNT CNT + 1 CNT 1 k = k - m k k - m k m return A, CNT return A, CNT A CNT m m A A CNT CNT n = int(input()) n int(input()) int input() input a = [] a [] for i in range(0, n):
	a.append(int(input())) i range(0, n) range 0 n a.append(int(input())) a.append a append int(input()) int input() input cnt = 0 cnt 0 M = [] M [] temp = 1 temp 1 while temp <= n:
	M.append(temp)
	temp = 3 * temp + 1 temp <= n temp n M.append(temp) M.append M append temp temp = 3 * temp + 1 temp 3 * temp + 1 3 * temp 3 temp 1 M.sort(reverse=True) M.sort M sort reverse=True reverse True for j in M:
	a, cnt = insertionSort(j, a, cnt) j M a, cnt = insertionSort(j, a, cnt) a insertionSort(j, a, cnt) insertionSort j a cnt cnt print(len(M)) print len(M) len M str(n) for n in M for n in M n M for n in M str(n) str n print(' '.join([str(n) for n in M])) print ' '.join([str(n) for n in M]) ' '.join ' ' join [str(n) for n in M] print(cnt) print cnt for k in a:
	print(k) k a print(k) print k def insertionSort(A):
	for i in range(1, len(A)):
		j = A[i]
		k = i
		while k - 1 >= 0:
			if A[k - 1] > j:
				A[k] = A[k - 1]
				A[k - 1] = j
			k = k - 1
	return A def insertionSort(A):
	for i in range(1, len(A)):
		j = A[i]
		k = i
		while k - 1 >= 0:
			if A[k - 1] > j:
				A[k] = A[k - 1]
				A[k - 1] = j
			k = k - 1
	return A insertionSort temp = 3 * temp + 1 3 * temp + 1 temp M = [] [] M def insertionSort(m, A, CNT):
	for i in range(m, len(A)):
		j = A[i]
		k = i
		while k - m >= 0 and A[k-m] > j:
			A[k] = A[k - m]
			A[k - m] = j
			CNT = CNT + 1
			k = k - m
#	while k - m >= 0:
#		if A[k - m] > j:
#			A[k] = A[k - m]
#			A[k - m] = j
#			CNT = CNT + 1
#		k = k - m
	return A, CNT def insertionSort(m, A, CNT):
	for i in range(m, len(A)):
		j = A[i]
		k = i
		while k - m >= 0 and A[k-m] > j:
			A[k] = A[k - m]
			A[k - m] = j
			CNT = CNT + 1
			k = k - m
#	while k - m >= 0:
#		if A[k - m] > j:
#			A[k] = A[k - m]
#			A[k - m] = j
#			CNT = CNT + 1
#		k = k - m
	return A, CNT insertionSort cnt = insertionSort(j, a, cnt) insertionSort(j, a, cnt) cnt a = [] [] a cnt = 0 0 cnt temp = 1 1 temp n = int(input()) int(input()) n a, cnt = insertionSort(j, a, cnt) insertionSort(j, a, cnt) a
def insertionSort(A):
	for i in range(1, len(A)):
		j = A[i]
		k = i
		while k - 1 >= 0:
			if A[k - 1] > j:
				A[k] = A[k - 1]
				A[k - 1] = j
			k = k - 1
	return A


def insertionSort(m, A, CNT):
	for i in range(m, len(A)):
		j = A[i]
		k = i
		while k - m >= 0 and A[k-m] > j:
			A[k] = A[k - m]
			A[k - m] = j
			CNT = CNT + 1
			k = k - m
#	while k - m >= 0:
#		if A[k - m] > j:
#			A[k] = A[k - m]
#			A[k - m] = j
#			CNT = CNT + 1
#		k = k - m
	return A, CNT


n = int(input())  # 例:6
a = []  # 例:[1, 4, 3, 6, 2, 5]
for i in range(0, n):
	a.append(int(input()))
cnt = 0

M = []
temp = 1
while temp <= n:
	M.append(temp)
	temp = 3 * temp + 1
M.sort(reverse=True)
#M=[1]
for j in M:
	a, cnt = insertionSort(j, a, cnt)

print(len(M))
print(' '.join([str(n) for n in M]))
print(cnt)
for k in a:
	print(k)

