from sys import stdin
from copy import deepcopy
input = stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]

B = deepcopy(A)
S = deepcopy(A)


def p(N):
    for i in range(len(N)):
        if i == len(N) - 1:
            print(N[i])
        else:
            print(N[i], end=" ")


cnt = 0


def insertionsort(n, g):
    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


def shellsort(n):
    h = 1
    G = []

    while h <= n:
        G.append(h)
        h = 3 * h + 1

    G.reverse()
    m = len(G)

    print(m)
    p(G)

    for i in range(0, m):
        insertionsort(n, G[i])


shellsort(N)

print(cnt)

for a in A:
    print(a)
 from sys import stdin from copy import deepcopy input = stdin.readline input stdin.readline stdin readline N = int(input()) N int(input()) int input() input int(input()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(input()) int input() input A = [int(input()) for _ in range(N)] A [int(input()) for _ in range(N)] B = deepcopy(A) B deepcopy(A) deepcopy A S = deepcopy(A) S deepcopy(A) deepcopy A def p(N):
    for i in range(len(N)):
        if i == len(N) - 1:
            print(N[i])
        else:
            print(N[i], end=" ") p for i in range(len(N)):
        if i == len(N) - 1:
            print(N[i])
        else:
            print(N[i], end=" ") i range(len(N)) range len(N) len N if i == len(N) - 1:
            print(N[i])
        else:
            print(N[i], end=" ") i == len(N) - 1 i len(N) - 1 len(N) len N 1 print(N[i]) print N[i] N i print(N[i], end=" ") print N[i] N i end=" " end " " N N cnt = 0 cnt 0 def insertionsort(n, g):
    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 insertionsort 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 n n g g def shellsort(n):
    h = 1
    G = []

    while h <= n:
        G.append(h)
        h = 3 * h + 1

    G.reverse()
    m = len(G)

    print(m)
    p(G)

    for i in range(0, m):
        insertionsort(n, G[i]) shellsort h = 1 h 1 G = [] G [] while h <= n:
        G.append(h)
        h = 3 * h + 1

     h <= n h n G.append(h) G.append G append h h = 3 * h + 1 h 3 * h + 1 3 * h 3 h 1 G.reverse() G.reverse G reverse m = len(G) m len(G) len G print(m) print m p(G) p G for i in range(0, m):
        insertionsort(n, G[i]) i range(0, m) range 0 m insertionsort(n, G[i]) insertionsort n G[i] G i n n shellsort(N) shellsort N print(cnt) print cnt for a in A:
    print(a) a A print(a) print a input = stdin.readline stdin.readline input def insertionsort(n, g):
    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 def insertionsort(n, g):
    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 insertionsort N = int(input()) int(input()) N def p(N):
    for i in range(len(N)):
        if i == len(N) - 1:
            print(N[i])
        else:
            print(N[i], end=" ") def p(N):
    for i in range(len(N)):
        if i == len(N) - 1:
            print(N[i])
        else:
            print(N[i], end=" ") p def shellsort(n):
    h = 1
    G = []

    while h <= n:
        G.append(h)
        h = 3 * h + 1

    G.reverse()
    m = len(G)

    print(m)
    p(G)

    for i in range(0, m):
        insertionsort(n, G[i]) def shellsort(n):
    h = 1
    G = []

    while h <= n:
        G.append(h)
        h = 3 * h + 1

    G.reverse()
    m = len(G)

    print(m)
    p(G)

    for i in range(0, m):
        insertionsort(n, G[i]) shellsort B = deepcopy(A) deepcopy(A) B cnt = 0 0 cnt A = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] A S = deepcopy(A) deepcopy(A) S
from sys import stdin
from copy import deepcopy
input = stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]

B = deepcopy(A)
S = deepcopy(A)


def p(N):
    for i in range(len(N)):
        if i == len(N) - 1:
            print(N[i])
        else:
            print(N[i], end=" ")


cnt = 0


def insertionsort(n, g):
    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


def shellsort(n):
    h = 1
    G = []

    while h <= n:
        G.append(h)
        h = 3 * h + 1

    G.reverse()
    m = len(G)

    print(m)
    p(G)

    for i in range(0, m):
        insertionsort(n, G[i])


shellsort(N)

print(cnt)

for a in A:
    print(a)

