def insertionSort(A, n, g, 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 cnt

def shellSort(A, n):
    cnt_s = 0
    k = 0
    G = []
    while k <= n:
        k = 3*k + 1
        if k <= n:
            G.append(k)
    G.reverse()
    m = len(G)
    for i in range(m):
        cnt_s = insertionSort(A, n, G[i], cnt_s)

    return A, m, G, cnt_s

n = int(input())
A = [0]*n

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

A_out, m, G, cnt_out = shellSort(A, n)

G_str = list(map(str,G))
print(str(m))
print(" ".join(G_str))
print(str(cnt_out))
for i in range(n):
    print(str(A_out[i])) def insertionSort(A, n, g, 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 cnt insertionSort 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 cnt cnt A A n n g g cnt cnt def shellSort(A, n):
    cnt_s = 0
    k = 0
    G = []
    while k <= n:
        k = 3*k + 1
        if k <= n:
            G.append(k)
    G.reverse()
    m = len(G)
    for i in range(m):
        cnt_s = insertionSort(A, n, G[i], cnt_s)

    return A, m, G, cnt_s shellSort cnt_s = 0 cnt_s 0 k = 0 k 0 G = [] G [] while k <= n:
        k = 3*k + 1
        if k <= n:
            G.append(k)
     k <= n k n k = 3*k + 1 k 3*k + 1 3*k 3 k 1 if k <= n:
            G.append(k)
     k <= n k n G.append(k) G.append G append k G.reverse() G.reverse G reverse m = len(G) m len(G) len G for i in range(m):
        cnt_s = insertionSort(A, n, G[i], cnt_s)

     i range(m) range m cnt_s = insertionSort(A, n, G[i], cnt_s) cnt_s insertionSort(A, n, G[i], cnt_s) insertionSort A n G[i] G i cnt_s return A, m, G, cnt_s return A, m, G, cnt_s A m G cnt_s A A n n n = int(input()) n int(input()) int input() input A = [0]*n A [0]*n [0] 0 n for i in range(n):
    A[i] = int(input()) i range(n) range n A[i] = int(input()) A[i] A i int(input()) int input() input A_out, m, G, cnt_out = shellSort(A, n) A_out shellSort(A, n) shellSort A n m G cnt_out G_str = list(map(str,G)) G_str list(map(str,G)) list map(str,G) map str G print(str(m)) print str(m) str m print(" ".join(G_str)) print " ".join(G_str) " ".join " " join G_str print(str(cnt_out)) print str(cnt_out) str cnt_out for i in range(n):
    print(str(A_out[i])) i range(n) range n print(str(A_out[i])) print str(A_out[i]) str A_out[i] A_out i def shellSort(A, n):
    cnt_s = 0
    k = 0
    G = []
    while k <= n:
        k = 3*k + 1
        if k <= n:
            G.append(k)
    G.reverse()
    m = len(G)
    for i in range(m):
        cnt_s = insertionSort(A, n, G[i], cnt_s)

    return A, m, G, cnt_s def shellSort(A, n):
    cnt_s = 0
    k = 0
    G = []
    while k <= n:
        k = 3*k + 1
        if k <= n:
            G.append(k)
    G.reverse()
    m = len(G)
    for i in range(m):
        cnt_s = insertionSort(A, n, G[i], cnt_s)

    return A, m, G, cnt_s shellSort A_out, m, G, cnt_out = shellSort(A, n) shellSort(A, n) A_out n = int(input()) int(input()) n A = [0]*n [0]*n A G_str = list(map(str,G)) list(map(str,G)) G_str cnt_out = shellSort(A, n) shellSort(A, n) cnt_out G, cnt_out = shellSort(A, n) shellSort(A, n) G def insertionSort(A, n, g, 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 cnt def insertionSort(A, n, g, 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 cnt insertionSort m, G, cnt_out = shellSort(A, n) shellSort(A, n) m
def insertionSort(A, n, g, 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 cnt

def shellSort(A, n):
    cnt_s = 0
    k = 0
    G = []
    while k <= n:
        k = 3*k + 1
        if k <= n:
            G.append(k)
    G.reverse()
    m = len(G)
    for i in range(m):
        cnt_s = insertionSort(A, n, G[i], cnt_s)

    return A, m, G, cnt_s

n = int(input())
A = [0]*n

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

A_out, m, G, cnt_out = shellSort(A, n)

G_str = list(map(str,G))
print(str(m))
print(" ".join(G_str))
print(str(cnt_out))
for i in range(n):
    print(str(A_out[i]))
