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, g):
	n = len(arr)
	cnt = 0
	for i in range(n):
		key = arr[i]
		j = i - g
		while j >= 0 and arr[j] > key:
			arr[j + g] = arr[j]
			j -= g
			cnt += 1
		arr[j + g] = key
	return cnt

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

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

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

G = get_gaps(n)
cnt = shell_sort(arr, G)

print(len(G))
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, g):
	n = len(arr)
	cnt = 0
	for i in range(n):
		key = arr[i]
		j = i - g
		while j >= 0 and arr[j] > key:
			arr[j + g] = arr[j]
			j -= g
			cnt += 1
		arr[j + g] = key
	return cnt insertion_sort n = len(arr) n len(arr) len arr cnt = 0 cnt 0 for i in range(n):
		key = arr[i]
		j = i - g
		while j >= 0 and arr[j] > key:
			arr[j + g] = arr[j]
			j -= g
			cnt += 1
		arr[j + g] = key
	 i range(n) range n key = arr[i] key arr[i] arr i j = i - g j i - g i g while j >= 0 and arr[j] > key:
			arr[j + g] = arr[j]
			j -= g
			cnt += 1
		 j >= 0 and arr[j] > key j >= 0 j 0 arr[j] > key arr[j] arr j key arr[j + g] = arr[j] arr[j + g] arr j + g j g arr[j] arr j j -= g j g cnt += 1 cnt 1 arr[j + g] = key arr[j + g] arr j + g j g key return cnt cnt arr arr g g def shell_sort(arr, G):
	cnt = 0
	for i in range(len(G)):
		cnt += insertion_sort(arr, G[i])
	return cnt shell_sort cnt = 0 cnt 0 for i in range(len(G)):
		cnt += insertion_sort(arr, G[i])
	 i range(len(G)) range len(G) len G cnt += insertion_sort(arr, G[i]) cnt insertion_sort(arr, G[i]) insertion_sort arr G[i] G i return cnt cnt arr arr G G def get_gaps(n):
	lst = []
	v = 1
	cnt = 1
	while v <= n:
		lst.append(v)
		v += 3**cnt
		cnt += 1
	if len(lst) == 0: lst.append(1)
	return list(reversed(lst)) get_gaps lst = [] lst [] v = 1 v 1 cnt = 1 cnt 1 while v <= n:
		lst.append(v)
		v += 3**cnt
		cnt += 1
	 v <= n v n 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 n n n = int(input()) n int(input()) int input() input arr = [None] * n arr [None] * n [None] None 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_gaps(n) G get_gaps(n) get_gaps n cnt = shell_sort(arr, G) cnt shell_sort(arr, G) shell_sort arr G print(len(G)) print len(G) len G 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 n = int(input()) int(input()) n def get_gaps(n):
	lst = []
	v = 1
	cnt = 1
	while v <= n:
		lst.append(v)
		v += 3**cnt
		cnt += 1
	if len(lst) == 0: lst.append(1)
	return list(reversed(lst)) def get_gaps(n):
	lst = []
	v = 1
	cnt = 1
	while v <= n:
		lst.append(v)
		v += 3**cnt
		cnt += 1
	if len(lst) == 0: lst.append(1)
	return list(reversed(lst)) get_gaps arr = [None] * n [None] * n arr G = get_gaps(n) get_gaps(n) G 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 def insertion_sort(arr, g):
	n = len(arr)
	cnt = 0
	for i in range(n):
		key = arr[i]
		j = i - g
		while j >= 0 and arr[j] > key:
			arr[j + g] = arr[j]
			j -= g
			cnt += 1
		arr[j + g] = key
	return cnt def insertion_sort(arr, g):
	n = len(arr)
	cnt = 0
	for i in range(n):
		key = arr[i]
		j = i - g
		while j >= 0 and arr[j] > key:
			arr[j + g] = arr[j]
			j -= g
			cnt += 1
		arr[j + g] = key
	return cnt insertion_sort def shell_sort(arr, G):
	cnt = 0
	for i in range(len(G)):
		cnt += insertion_sort(arr, G[i])
	return cnt def shell_sort(arr, G):
	cnt = 0
	for i in range(len(G)):
		cnt += insertion_sort(arr, G[i])
	return cnt shell_sort cnt = shell_sort(arr, G) shell_sort(arr, G) cnt
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, g):
	n = len(arr)
	cnt = 0
	for i in range(n):
		key = arr[i]
		j = i - g
		while j >= 0 and arr[j] > key:
			arr[j + g] = arr[j]
			j -= g
			cnt += 1
		arr[j + g] = key
	return cnt

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

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

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

G = get_gaps(n)
cnt = shell_sort(arr, G)

print(len(G))
print_arr(G)
print(cnt)
for i in range(n):
	print(arr[i])

