
# shell sort
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/2/ALDS1_2_D

import sys
readline = sys.stdin.buffer.readline
cnt = 0


def insersion_sort(A: list, n: int, g: int):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v
    return


def shell_sort(A: list, n: int):
    # 数列 G = {1,4,13,40,121,363,...}を生成
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = h * 3 + 1
    G = G[::-1]
    print(len(G))
    print(" ".join([str(g) for g in G]))
    for g in G:
        insersion_sort(A, n, g)
    return A


n = int(readline())
A = []

for _ in range(n):
    A.append(int(readline()))

shell_sort(A, n)
print(cnt)
for a in A:
    print(a)
 import sys sys readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline cnt = 0 cnt 0 def insersion_sort(A: list, n: int, g: int):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v
    return insersion_sort global cnt for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v
     i range(g, n) range g n v = A[i] v A[i] A i j = i - g j i - g i g while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
         j >= 0 and A[j] > v j >= 0 j 0 A[j] > v A[j] A j v 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 return A: list A n: int n g: int g def shell_sort(A: list, n: int):
    # 数列 G = {1,4,13,40,121,363,...}を生成
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = h * 3 + 1
    G = G[::-1]
    print(len(G))
    print(" ".join([str(g) for g in G]))
    for g in G:
        insersion_sort(A, n, g)
    return A shell_sort G = [] G [] h = 1 h 1 while h <= n:
        G.append(h)
        h = h * 3 + 1
     h <= n h n G.append(h) G.append G append h h = h * 3 + 1 h h * 3 + 1 h * 3 h 3 1 G = G[::-1] G G[::-1] G ::-1 -1 print(len(G)) print len(G) len G str(g) for g in G for g in G g G for g in G str(g) str g print(" ".join([str(g) for g in G])) print " ".join([str(g) for g in G]) " ".join " " join [str(g) for g in G] for g in G:
        insersion_sort(A, n, g)
     g G insersion_sort(A, n, g) insersion_sort A n g return A A A: list A n: int n n = int(readline()) n int(readline()) int readline() readline A = [] A [] for _ in range(n):
    A.append(int(readline())) _ range(n) range n A.append(int(readline())) A.append A append int(readline()) int readline() readline shell_sort(A, n) shell_sort A n print(cnt) print cnt for a in A:
    print(a) a A print(a) print a def insersion_sort(A: list, n: int, g: int):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v
    return def insersion_sort(A: list, n: int, g: int):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v
    return insersion_sort def shell_sort(A: list, n: int):
    # 数列 G = {1,4,13,40,121,363,...}を生成
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = h * 3 + 1
    G = G[::-1]
    print(len(G))
    print(" ".join([str(g) for g in G]))
    for g in G:
        insersion_sort(A, n, g)
    return A def shell_sort(A: list, n: int):
    # 数列 G = {1,4,13,40,121,363,...}を生成
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = h * 3 + 1
    G = G[::-1]
    print(len(G))
    print(" ".join([str(g) for g in G]))
    for g in G:
        insersion_sort(A, n, g)
    return A shell_sort n = int(readline()) int(readline()) n A = [] [] A readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline cnt = 0 0 cnt

# shell sort
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/2/ALDS1_2_D

import sys
readline = sys.stdin.buffer.readline
cnt = 0


def insersion_sort(A: list, n: int, g: int):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v
    return


def shell_sort(A: list, n: int):
    # 数列 G = {1,4,13,40,121,363,...}を生成
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = h * 3 + 1
    G = G[::-1]
    print(len(G))
    print(" ".join([str(g) for g in G]))
    for g in G:
        insersion_sort(A, n, g)
    return A


n = int(readline())
A = []

for _ in range(n):
    A.append(int(readline()))

shell_sort(A, n)
print(cnt)
for a in A:
    print(a)

