#coding:utf-8
#1_2_D
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 -= g
            cnt += 1
        A[j+g] = v

def shellSort(A, n):
    G = [1]
    while True:
        g = 3*G[0] + 1
        if g > n:
            break
        G.insert(0, g)
    m = len(G)
    for i in range(m):
        insertionSort(A, n, G[i])
    return [m, G]

n = int(input())
A = [int(input()) for i in range(n)]
cnt = 0
m, G = shellSort(A, n)
print(m)
print(" ".join(map(str, G)))
print(cnt)
print("\n".join(map(str, 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 -= 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 -= 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 -= 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 -= 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]
    while True:
        g = 3*G[0] + 1
        if g > n:
            break
        G.insert(0, g)
    m = len(G)
    for i in range(m):
        insertionSort(A, n, G[i])
    return [m, G] shellSort G = [1] G [1] 1 while True:
        g = 3*G[0] + 1
        if g > n:
            break
        G.insert(0, g)
     True g = 3*G[0] + 1 g 3*G[0] + 1 3*G[0] 3 G[0] G 0 1 if g > n:
            break
         g > n g n break G.insert(0, g) G.insert G insert 0 g m = len(G) m len(G) len 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 return [m, G] [m, G] m G A A n n n = int(input()) n int(input()) int input() input int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input A = [int(input()) for i in range(n)] A [int(input()) for i in range(n)] cnt = 0 cnt 0 m, G = shellSort(A, n) m shellSort(A, n) shellSort A n G print(m) print m print(" ".join(map(str, G))) print " ".join(map(str, G)) " ".join " " join map(str, G) map str G print(cnt) print cnt print("\n".join(map(str, A))) print "\n".join(map(str, A)) "\n".join "\n" join map(str, A) map str A m, G = shellSort(A, n) shellSort(A, n) m G = shellSort(A, n) shellSort(A, n) G A = [int(input()) for i in range(n)] [int(input()) for i 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 -= 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 -= g
            cnt += 1
        A[j+g] = v insertionSort n = int(input()) int(input()) n cnt = 0 0 cnt def shellSort(A, n):
    G = [1]
    while True:
        g = 3*G[0] + 1
        if g > n:
            break
        G.insert(0, g)
    m = len(G)
    for i in range(m):
        insertionSort(A, n, G[i])
    return [m, G] def shellSort(A, n):
    G = [1]
    while True:
        g = 3*G[0] + 1
        if g > n:
            break
        G.insert(0, g)
    m = len(G)
    for i in range(m):
        insertionSort(A, n, G[i])
    return [m, G] shellSort
#coding:utf-8
#1_2_D
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 -= g
            cnt += 1
        A[j+g] = v

def shellSort(A, n):
    G = [1]
    while True:
        g = 3*G[0] + 1
        if g > n:
            break
        G.insert(0, g)
    m = len(G)
    for i in range(m):
        insertionSort(A, n, G[i])
    return [m, G]

n = int(input())
A = [int(input()) for i in range(n)]
cnt = 0
m, G = shellSort(A, n)
print(m)
print(" ".join(map(str, G)))
print(cnt)
print("\n".join(map(str, A)))