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
    global m
    global G
    for i in range(m):
        insertionSort(A, n, G[i])


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

cnt = 0
G = [1]
while G[-1] < n/9:
    G.append(G[-1]*3 + 1)
G.reverse()
m = len(G)

shellSort(A, n)
print(m)
print(" ".join(map(str, G)))
print(cnt)
for i in A:
    print(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
    global m
    global G
    for i in range(m):
        insertionSort(A, n, G[i]) shellSort global cnt global m global 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 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 G = [1] G [1] 1 while G[-1] < n/9:
    G.append(G[-1]*3 + 1) G[-1] < n/9 G[-1] G -1 n/9 n 9 G.append(G[-1]*3 + 1) G.append G append G[-1]*3 + 1 G[-1]*3 G[-1] G -1 3 1 G.reverse() G.reverse G reverse m = len(G) m len(G) len G shellSort(A, n) shellSort A n 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 for i in A:
    print(i) i A print(i) print i m = len(G) len(G) m 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 n = int(input()) int(input()) n A = [int(input()) for i in range(n)] [int(input()) for i in range(n)] A G = [1] [1] G def shellSort(A, n):
    global cnt
    global m
    global G
    for i in range(m):
        insertionSort(A, n, G[i]) def shellSort(A, n):
    global cnt
    global m
    global G
    for i in range(m):
        insertionSort(A, n, G[i]) shellSort cnt = 0 0 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
    global m
    global G
    for i in range(m):
        insertionSort(A, n, G[i])


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

cnt = 0
G = [1]
while G[-1] < n/9:
    G.append(G[-1]*3 + 1)
G.reverse()
m = len(G)

shellSort(A, n)
print(m)
print(" ".join(map(str, G)))
print(cnt)
for i in A:
    print(i)