import sys


def insert_sort(A, n, g):
    global cnt

    # 指定値のgからリストの大きさまで繰り返す
    for i in range(g, n, 1):
        # print(f"bef{A=}")
        # 最初にヒットした数値
        v = A[i]
        j = i - g
        # print(f"{j=}")
        while 0 <= j and v < A[j]:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
        # print(f"aft{A=}")


n = int(input())
A = [x for x in map(int, sys.stdin)]

cnt = 0
G = [1]
while n >= 3*G[-1] + 1:
    G.append(3*G[-1] + 1)


for g in G[::-1]:
    insert_sort(A, n, g)
print(len(G))
G.reverse()
print(*G)
print(cnt)
for a in A:
    print(a)

 import sys sys def insert_sort(A, n, g):
    global cnt

    # 指定値のgからリストの大きさまで繰り返す
    for i in range(g, n, 1):
        # print(f"bef{A=}")
        # 最初にヒットした数値
        v = A[i]
        j = i - g
        # print(f"{j=}")
        while 0 <= j and v < A[j]:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
        # print(f"aft{A=}") insert_sort global cnt for i in range(g, n, 1):
        # print(f"bef{A=}")
        # 最初にヒットした数値
        v = A[i]
        j = i - g
        # print(f"{j=}")
        while 0 <= j and v < A[j]:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
        # print(f"aft{A=}") i range(g, n, 1) range g n 1 v = A[i] v A[i] A i j = i - g j i - g i g while 0 <= j and v < A[j]:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
         0 <= j and v < A[j] 0 <= j 0 j v < A[j] v A[j] A j 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 n = int(input()) n int(input()) int input() input x for x in map(int, sys.stdin) for x in map(int, sys.stdin) x map(int, sys.stdin) map int sys.stdin sys stdin for x in map(int, sys.stdin) x A = [x for x in map(int, sys.stdin)] A [x for x in map(int, sys.stdin)] cnt = 0 cnt 0 G = [1] G [1] 1 while n >= 3*G[-1] + 1:
    G.append(3*G[-1] + 1) n >= 3*G[-1] + 1 n 3*G[-1] + 1 3*G[-1] 3 G[-1] G -1 1 G.append(3*G[-1] + 1) G.append G append 3*G[-1] + 1 3*G[-1] 3 G[-1] G -1 1 for g in G[::-1]:
    insert_sort(A, n, g) g G[::-1] G ::-1 -1 insert_sort(A, n, g) insert_sort A n g print(len(G)) print len(G) len G G.reverse() G.reverse G reverse print(*G) print *G G print(cnt) print cnt for a in A:
    print(a) a A print(a) print a def insert_sort(A, n, g):
    global cnt

    # 指定値のgからリストの大きさまで繰り返す
    for i in range(g, n, 1):
        # print(f"bef{A=}")
        # 最初にヒットした数値
        v = A[i]
        j = i - g
        # print(f"{j=}")
        while 0 <= j and v < A[j]:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
        # print(f"aft{A=}") def insert_sort(A, n, g):
    global cnt

    # 指定値のgからリストの大きさまで繰り返す
    for i in range(g, n, 1):
        # print(f"bef{A=}")
        # 最初にヒットした数値
        v = A[i]
        j = i - g
        # print(f"{j=}")
        while 0 <= j and v < A[j]:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
        # print(f"aft{A=}") insert_sort G = [1] [1] G n = int(input()) int(input()) n A = [x for x in map(int, sys.stdin)] [x for x in map(int, sys.stdin)] A cnt = 0 0 cnt
import sys


def insert_sort(A, n, g):
    global cnt

    # 指定値のgからリストの大きさまで繰り返す
    for i in range(g, n, 1):
        # print(f"bef{A=}")
        # 最初にヒットした数値
        v = A[i]
        j = i - g
        # print(f"{j=}")
        while 0 <= j and v < A[j]:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
        # print(f"aft{A=}")


n = int(input())
A = [x for x in map(int, sys.stdin)]

cnt = 0
G = [1]
while n >= 3*G[-1] + 1:
    G.append(3*G[-1] + 1)


for g in G[::-1]:
    insert_sort(A, n, g)
print(len(G))
G.reverse()
print(*G)
print(cnt)
for a in A:
    print(a)


