import math
def shell(l):
	N = len(l)
	cnt = 0
	m = int(math.log(2 * N + 1, 3))
	G = [(3 ** i - 1) // 2 for i in range(m, 0, -1)]

	for i in range(m):
		l, cnt = insert(l, G[i], cnt)

	return l, m, G, cnt

def insert(l, g, cnt):
	N = len(l)

	for i in range(g, N):
		v = l[i]
		j = i - g

		while j >= 0 and l[j] > v:
			l[j + g] = l[j]
			j -= g
			cnt += 1

		l[j + g] = v

	return l, cnt

def output(l):
	count = 0
	leng = len(l)
	for i in l:
		count += 1
		if count < leng:
			print(i, end =' ')
		else:
			print(i)




if __name__ == '__main__':
	n = int(input())
	lists = list()

	for i in range(n):
		lists.append(int(input()))

	lists, m, g, cnt = shell(lists)
	print(m)
	output(g)
	print(cnt)
	for i in lists:
		print(i)


 import math math def shell(l):
	N = len(l)
	cnt = 0
	m = int(math.log(2 * N + 1, 3))
	G = [(3 ** i - 1) // 2 for i in range(m, 0, -1)]

	for i in range(m):
		l, cnt = insert(l, G[i], cnt)

	return l, m, G, cnt shell N = len(l) N len(l) len l cnt = 0 cnt 0 m = int(math.log(2 * N + 1, 3)) m int(math.log(2 * N + 1, 3)) int math.log(2 * N + 1, 3) math.log math log 2 * N + 1 2 * N 2 N 1 3 (3 ** i - 1) // 2 for i in range(m, 0, -1) for i in range(m, 0, -1) i range(m, 0, -1) range m 0 -1 for i in range(m, 0, -1) (3 ** i - 1) // 2 3 ** i - 1 3 ** i 3 i 1 2 G = [(3 ** i - 1) // 2 for i in range(m, 0, -1)] G [(3 ** i - 1) // 2 for i in range(m, 0, -1)] for i in range(m):
		l, cnt = insert(l, G[i], cnt)

	 i range(m) range m l, cnt = insert(l, G[i], cnt) l insert(l, G[i], cnt) insert l G[i] G i cnt cnt return l, m, G, cnt return l, m, G, cnt l m G cnt l l def insert(l, g, cnt):
	N = len(l)

	for i in range(g, N):
		v = l[i]
		j = i - g

		while j >= 0 and l[j] > v:
			l[j + g] = l[j]
			j -= g
			cnt += 1

		l[j + g] = v

	return l, cnt insert N = len(l) N len(l) len l for i in range(g, N):
		v = l[i]
		j = i - g

		while j >= 0 and l[j] > v:
			l[j + g] = l[j]
			j -= g
			cnt += 1

		l[j + g] = v

	 i range(g, N) range g N v = l[i] v l[i] l i j = i - g j i - g i g while j >= 0 and l[j] > v:
			l[j + g] = l[j]
			j -= g
			cnt += 1

		 j >= 0 and l[j] > v j >= 0 j 0 l[j] > v l[j] l j v l[j + g] = l[j] l[j + g] l j + g j g l[j] l j j -= g j g cnt += 1 cnt 1 l[j + g] = v l[j + g] l j + g j g v return l, cnt return l, cnt l cnt l l g g cnt cnt def output(l):
	count = 0
	leng = len(l)
	for i in l:
		count += 1
		if count < leng:
			print(i, end =' ')
		else:
			print(i) output count = 0 count 0 leng = len(l) leng len(l) len l for i in l:
		count += 1
		if count < leng:
			print(i, end =' ')
		else:
			print(i) i l count += 1 count 1 if count < leng:
			print(i, end =' ')
		else:
			print(i) count < leng count leng print(i, end =' ') print i end =' ' end ' ' print(i) print i l l if __name__ == '__main__':
	n = int(input())
	lists = list()

	for i in range(n):
		lists.append(int(input()))

	lists, m, g, cnt = shell(lists)
	print(m)
	output(g)
	print(cnt)
	for i in lists:
		print(i) __name__ == '__main__' __name__ '__main__' n = int(input()) n int(input()) int input() input lists = list() lists list() list for i in range(n):
		lists.append(int(input()))

	 i range(n) range n lists.append(int(input())) lists.append lists append int(input()) int input() input lists, m, g, cnt = shell(lists) lists shell(lists) shell lists m g cnt print(m) print m output(g) output g print(cnt) print cnt for i in lists:
		print(i) i lists print(i) print i def insert(l, g, cnt):
	N = len(l)

	for i in range(g, N):
		v = l[i]
		j = i - g

		while j >= 0 and l[j] > v:
			l[j + g] = l[j]
			j -= g
			cnt += 1

		l[j + g] = v

	return l, cnt def insert(l, g, cnt):
	N = len(l)

	for i in range(g, N):
		v = l[i]
		j = i - g

		while j >= 0 and l[j] > v:
			l[j + g] = l[j]
			j -= g
			cnt += 1

		l[j + g] = v

	return l, cnt insert def shell(l):
	N = len(l)
	cnt = 0
	m = int(math.log(2 * N + 1, 3))
	G = [(3 ** i - 1) // 2 for i in range(m, 0, -1)]

	for i in range(m):
		l, cnt = insert(l, G[i], cnt)

	return l, m, G, cnt def shell(l):
	N = len(l)
	cnt = 0
	m = int(math.log(2 * N + 1, 3))
	G = [(3 ** i - 1) // 2 for i in range(m, 0, -1)]

	for i in range(m):
		l, cnt = insert(l, G[i], cnt)

	return l, m, G, cnt shell lists, m, g, cnt = shell(lists) shell(lists) lists m, g, cnt = shell(lists) shell(lists) m lists = list() list() lists g, cnt = shell(lists) shell(lists) g cnt = shell(lists) shell(lists) cnt def output(l):
	count = 0
	leng = len(l)
	for i in l:
		count += 1
		if count < leng:
			print(i, end =' ')
		else:
			print(i) def output(l):
	count = 0
	leng = len(l)
	for i in l:
		count += 1
		if count < leng:
			print(i, end =' ')
		else:
			print(i) output n = int(input()) int(input()) n
import math
def shell(l):
	N = len(l)
	cnt = 0
	m = int(math.log(2 * N + 1, 3))
	G = [(3 ** i - 1) // 2 for i in range(m, 0, -1)]

	for i in range(m):
		l, cnt = insert(l, G[i], cnt)

	return l, m, G, cnt

def insert(l, g, cnt):
	N = len(l)

	for i in range(g, N):
		v = l[i]
		j = i - g

		while j >= 0 and l[j] > v:
			l[j + g] = l[j]
			j -= g
			cnt += 1

		l[j + g] = v

	return l, cnt

def output(l):
	count = 0
	leng = len(l)
	for i in l:
		count += 1
		if count < leng:
			print(i, end =' ')
		else:
			print(i)




if __name__ == '__main__':
	n = int(input())
	lists = list()

	for i in range(n):
		lists.append(int(input()))

	lists, m, g, cnt = shell(lists)
	print(m)
	output(g)
	print(cnt)
	for i in lists:
		print(i)



