cnt = 0

def insertionSort(A, 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(A, n):
    G = [1]
    for i in range(1, 100):
        G.append(G[i - 1] * 3 + 1)

    G = list(reversed([g for g in G if g <= n]))
    m = len(G)
    print(m)
    if G:
        print(*G)

    for i in range(m):
        insertionSort(A, n, G[i])

    print(cnt)



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

shellSort(A, n)

[print(a) for a in A] cnt = 0 cnt 0 def insertionSort(A, 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 A A n n g g def shellSort(A, n):
    G = [1]
    for i in range(1, 100):
        G.append(G[i - 1] * 3 + 1)

    G = list(reversed([g for g in G if g <= n]))
    m = len(G)
    print(m)
    if G:
        print(*G)

    for i in range(m):
        insertionSort(A, n, G[i])

    print(cnt) shellSort G = [1] G [1] 1 for i in range(1, 100):
        G.append(G[i - 1] * 3 + 1)

     i range(1, 100) range 1 100 G.append(G[i - 1] * 3 + 1) G.append G append G[i - 1] * 3 + 1 G[i - 1] * 3 G[i - 1] G i - 1 i 1 3 1 g for g in G if g <= n for g in G if g <= n g G g <= n g n if g <= n g G = list(reversed([g for g in G if g <= n])) G list(reversed([g for g in G if g <= n])) list reversed([g for g in G if g <= n]) reversed [g for g in G if g <= n] m = len(G) m len(G) len G print(m) print m if G:
        print(*G)

     G print(*G) print *G G for i in range(m):
        insertionSort(A, n, G[i])

     i range(m) range m insertionSort(A, n, G[i]) insertionSort A n G[i] G i print(cnt) print cnt A A n n 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)] shellSort(A, n) shellSort A n print(a) for a in A for a in A a A for a in A print(a) print a [print(a) for a in A] A = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] A def insertionSort(A, 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(A, 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 cnt = 0 0 cnt def shellSort(A, n):
    G = [1]
    for i in range(1, 100):
        G.append(G[i - 1] * 3 + 1)

    G = list(reversed([g for g in G if g <= n]))
    m = len(G)
    print(m)
    if G:
        print(*G)

    for i in range(m):
        insertionSort(A, n, G[i])

    print(cnt) def shellSort(A, n):
    G = [1]
    for i in range(1, 100):
        G.append(G[i - 1] * 3 + 1)

    G = list(reversed([g for g in G if g <= n]))
    m = len(G)
    print(m)
    if G:
        print(*G)

    for i in range(m):
        insertionSort(A, n, G[i])

    print(cnt) shellSort n = int(input()) int(input()) n
cnt = 0

def insertionSort(A, 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(A, n):
    G = [1]
    for i in range(1, 100):
        G.append(G[i - 1] * 3 + 1)

    G = list(reversed([g for g in G if g <= n]))
    m = len(G)
    print(m)
    if G:
        print(*G)

    for i in range(m):
        insertionSort(A, n, G[i])

    print(cnt)



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

shellSort(A, n)

[print(a) for a in A]
