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):
    global cnt
    G = []
    g = 1
    while g <= n:
        G.append(g)
        g = 3 * g + 1
    G = G[::-1]
    m = len(G)
    for i in range(m):
        insertionSort(A, n, G[i])
    return m, G, cnt, A

n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))
cnt = 0
m, G, cnt, A = shellSort(A, n)
print(m)
for i in range(m):
    if i == m - 1:
        print(G[i])
    else:
        print(G[i], end=' ')
print(cnt)
for i in range(n):
    print(A[i]) 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):
    global cnt
    G = []
    g = 1
    while g <= n:
        G.append(g)
        g = 3 * g + 1
    G = G[::-1]
    m = len(G)
    for i in range(m):
        insertionSort(A, n, G[i])
    return m, G, cnt, A shellSort global cnt G = [] G [] g = 1 g 1 while g <= n:
        G.append(g)
        g = 3 * g + 1
     g <= n g n G.append(g) G.append G append g g = 3 * g + 1 g 3 * g + 1 3 * g 3 g 1 G = G[::-1] G G[::-1] G ::-1 -1 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, cnt, A return m, G, cnt, A m G cnt A A A n n n = int(input()) n int(input()) int input() input A = [] A [] for _ in range(n):
    A.append(int(input())) _ range(n) range n A.append(int(input())) A.append A append int(input()) int input() input cnt = 0 cnt 0 m, G, cnt, A = shellSort(A, n) m shellSort(A, n) shellSort A n G cnt A print(m) print m for i in range(m):
    if i == m - 1:
        print(G[i])
    else:
        print(G[i], end=' ') i range(m) range m if i == m - 1:
        print(G[i])
    else:
        print(G[i], end=' ') i == m - 1 i m - 1 m 1 print(G[i]) print G[i] G i print(G[i], end=' ') print G[i] G i end=' ' end ' ' print(cnt) print cnt for i in range(n):
    print(A[i]) i range(n) range n print(A[i]) print A[i] A i n = int(input()) int(input()) n A = [] [] A G, cnt, A = shellSort(A, n) shellSort(A, n) G 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 def shellSort(A, n):
    global cnt
    G = []
    g = 1
    while g <= n:
        G.append(g)
        g = 3 * g + 1
    G = G[::-1]
    m = len(G)
    for i in range(m):
        insertionSort(A, n, G[i])
    return m, G, cnt, A def shellSort(A, n):
    global cnt
    G = []
    g = 1
    while g <= n:
        G.append(g)
        g = 3 * g + 1
    G = G[::-1]
    m = len(G)
    for i in range(m):
        insertionSort(A, n, G[i])
    return m, G, cnt, A shellSort m, G, cnt, A = shellSort(A, n) shellSort(A, n) m A = shellSort(A, n) shellSort(A, n) A cnt = 0 0 cnt cnt, A = shellSort(A, n) shellSort(A, n) cnt
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):
    global cnt
    G = []
    g = 1
    while g <= n:
        G.append(g)
        g = 3 * g + 1
    G = G[::-1]
    m = len(G)
    for i in range(m):
        insertionSort(A, n, G[i])
    return m, G, cnt, A

n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))
cnt = 0
m, G, cnt, A = shellSort(A, n)
print(m)
for i in range(m):
    if i == m - 1:
        print(G[i])
    else:
        print(G[i], end=' ')
print(cnt)
for i in range(n):
    print(A[i])
