import sys

def print_arr(arr):
	for i in range(len(arr)):
		sys.stdout.write(str(arr[i]))
		if i != len(arr) - 1:
			sys.stdout.write(' ')
	print()

def insertion_sort(arr, n, g):
	cnt = 0
	for i in range(g, n):
		v = arr[i]
		j = i - g
		while j >= 0 and arr[j] > v:
			arr[j + g] = arr[j]
			j = j - g
			cnt += 1
		arr[j + g] = v
	return cnt

def shell_sort(arr, g):
	cnt = 0
	for i in range(len(g)):
		cnt += insertion_sort(arr, len(arr), g[i])
	return cnt

def get_gap(gap):
	lst = []
	v = 1
	cnt = 1
	while v <= gap:
		lst.append(v)
		v += 3**cnt
		cnt += 1
	if len(lst) == 0: lst.append(1)
	return list(reversed(lst))

n = int(input())
arr = [0] * n
for i in range(n):
	arr[i] = int(input())

g = get_gap(n)
m = len(g)
cnt = shell_sort(arr, g)

print(m)
print_arr(g)
print(cnt)
for i in range(n):
	print(arr[i])
 import sys sys def print_arr(arr):
	for i in range(len(arr)):
		sys.stdout.write(str(arr[i]))
		if i != len(arr) - 1:
			sys.stdout.write(' ')
	print() print_arr for i in range(len(arr)):
		sys.stdout.write(str(arr[i]))
		if i != len(arr) - 1:
			sys.stdout.write(' ')
	 i range(len(arr)) range len(arr) len arr sys.stdout.write(str(arr[i])) sys.stdout.write sys.stdout sys stdout write str(arr[i]) str arr[i] arr i if i != len(arr) - 1:
			sys.stdout.write(' ')
	 i != len(arr) - 1 i len(arr) - 1 len(arr) len arr 1 sys.stdout.write(' ') sys.stdout.write sys.stdout sys stdout write ' ' print() print arr arr def insertion_sort(arr, n, g):
	cnt = 0
	for i in range(g, n):
		v = arr[i]
		j = i - g
		while j >= 0 and arr[j] > v:
			arr[j + g] = arr[j]
			j = j - g
			cnt += 1
		arr[j + g] = v
	return cnt insertion_sort cnt = 0 cnt 0 for i in range(g, n):
		v = arr[i]
		j = i - g
		while j >= 0 and arr[j] > v:
			arr[j + g] = arr[j]
			j = j - g
			cnt += 1
		arr[j + g] = v
	 i range(g, n) range g n v = arr[i] v arr[i] arr i j = i - g j i - g i g while j >= 0 and arr[j] > v:
			arr[j + g] = arr[j]
			j = j - g
			cnt += 1
		 j >= 0 and arr[j] > v j >= 0 j 0 arr[j] > v arr[j] arr j v arr[j + g] = arr[j] arr[j + g] arr j + g j g arr[j] arr j j = j - g j j - g j g cnt += 1 cnt 1 arr[j + g] = v arr[j + g] arr j + g j g v return cnt cnt arr arr n n g g def shell_sort(arr, g):
	cnt = 0
	for i in range(len(g)):
		cnt += insertion_sort(arr, len(arr), g[i])
	return cnt shell_sort cnt = 0 cnt 0 for i in range(len(g)):
		cnt += insertion_sort(arr, len(arr), g[i])
	 i range(len(g)) range len(g) len g cnt += insertion_sort(arr, len(arr), g[i]) cnt insertion_sort(arr, len(arr), g[i]) insertion_sort arr len(arr) len arr g[i] g i return cnt cnt arr arr g g def get_gap(gap):
	lst = []
	v = 1
	cnt = 1
	while v <= gap:
		lst.append(v)
		v += 3**cnt
		cnt += 1
	if len(lst) == 0: lst.append(1)
	return list(reversed(lst)) get_gap lst = [] lst [] v = 1 v 1 cnt = 1 cnt 1 while v <= gap:
		lst.append(v)
		v += 3**cnt
		cnt += 1
	 v <= gap v gap lst.append(v) lst.append lst append v v += 3**cnt v 3**cnt 3 cnt cnt += 1 cnt 1 if len(lst) == 0: lst.append(1)
	 len(lst) == 0 len(lst) len lst 0 return list(reversed(lst)) list(reversed(lst)) list reversed(lst) reversed lst gap gap n = int(input()) n int(input()) int input() input arr = [0] * n arr [0] * n [0] 0 n for i in range(n):
	arr[i] = int(input()) i range(n) range n arr[i] = int(input()) arr[i] arr i int(input()) int input() input g = get_gap(n) g get_gap(n) get_gap n m = len(g) m len(g) len g cnt = shell_sort(arr, g) cnt shell_sort(arr, g) shell_sort arr g print(m) print m print_arr(g) print_arr g print(cnt) print cnt for i in range(n):
	print(arr[i]) i range(n) range n print(arr[i]) print arr[i] arr i arr = [0] * n [0] * n arr def insertion_sort(arr, n, g):
	cnt = 0
	for i in range(g, n):
		v = arr[i]
		j = i - g
		while j >= 0 and arr[j] > v:
			arr[j + g] = arr[j]
			j = j - g
			cnt += 1
		arr[j + g] = v
	return cnt def insertion_sort(arr, n, g):
	cnt = 0
	for i in range(g, n):
		v = arr[i]
		j = i - g
		while j >= 0 and arr[j] > v:
			arr[j + g] = arr[j]
			j = j - g
			cnt += 1
		arr[j + g] = v
	return cnt insertion_sort def shell_sort(arr, g):
	cnt = 0
	for i in range(len(g)):
		cnt += insertion_sort(arr, len(arr), g[i])
	return cnt def shell_sort(arr, g):
	cnt = 0
	for i in range(len(g)):
		cnt += insertion_sort(arr, len(arr), g[i])
	return cnt shell_sort m = len(g) len(g) m def print_arr(arr):
	for i in range(len(arr)):
		sys.stdout.write(str(arr[i]))
		if i != len(arr) - 1:
			sys.stdout.write(' ')
	print() def print_arr(arr):
	for i in range(len(arr)):
		sys.stdout.write(str(arr[i]))
		if i != len(arr) - 1:
			sys.stdout.write(' ')
	print() print_arr g = get_gap(n) get_gap(n) g n = int(input()) int(input()) n cnt = shell_sort(arr, g) shell_sort(arr, g) cnt def get_gap(gap):
	lst = []
	v = 1
	cnt = 1
	while v <= gap:
		lst.append(v)
		v += 3**cnt
		cnt += 1
	if len(lst) == 0: lst.append(1)
	return list(reversed(lst)) def get_gap(gap):
	lst = []
	v = 1
	cnt = 1
	while v <= gap:
		lst.append(v)
		v += 3**cnt
		cnt += 1
	if len(lst) == 0: lst.append(1)
	return list(reversed(lst)) get_gap
import sys

def print_arr(arr):
	for i in range(len(arr)):
		sys.stdout.write(str(arr[i]))
		if i != len(arr) - 1:
			sys.stdout.write(' ')
	print()

def insertion_sort(arr, n, g):
	cnt = 0
	for i in range(g, n):
		v = arr[i]
		j = i - g
		while j >= 0 and arr[j] > v:
			arr[j + g] = arr[j]
			j = j - g
			cnt += 1
		arr[j + g] = v
	return cnt

def shell_sort(arr, g):
	cnt = 0
	for i in range(len(g)):
		cnt += insertion_sort(arr, len(arr), g[i])
	return cnt

def get_gap(gap):
	lst = []
	v = 1
	cnt = 1
	while v <= gap:
		lst.append(v)
		v += 3**cnt
		cnt += 1
	if len(lst) == 0: lst.append(1)
	return list(reversed(lst))

n = int(input())
arr = [0] * n
for i in range(n):
	arr[i] = int(input())

g = get_gap(n)
m = len(g)
cnt = shell_sort(arr, g)

print(m)
print_arr(g)
print(cnt)
for i in range(n):
	print(arr[i])

