def insertionSort(A, n, g):
    cnt_local = 0
    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_local += 1
        A[j+g] = v
    return cnt_local

cnt_all = 0
n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))

G = [int((3**i-1)/2)for i in range(17,0,-1)]
G = [v for v in G if v <= n]
m = len(G)
for i in range(m):
    cnt_all += insertionSort(A, n, G[i])

print(m)
print(*G)
print(cnt_all)
print(*A, sep='\n')
 def insertionSort(A, n, g):
    cnt_local = 0
    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_local += 1
        A[j+g] = v
    return cnt_local insertionSort cnt_local = 0 cnt_local 0 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_local += 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_local += 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_local += 1 cnt_local 1 A[j+g] = v A[j+g] A j+g j g v return cnt_local cnt_local A A n n g g cnt_all = 0 cnt_all 0 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 int((3**i-1)/2)for i in range(17,0,-1) for i in range(17,0,-1) i range(17,0,-1) range 17 0 -1 for i in range(17,0,-1) int((3**i-1)/2) int (3**i-1)/2 3**i-1 3**i 3 i 1 2 G = [int((3**i-1)/2)for i in range(17,0,-1)] G [int((3**i-1)/2)for i in range(17,0,-1)] v for v in G if v <= n for v in G if v <= n v G v <= n v n if v <= n v G = [v for v in G if v <= n] G [v for v in G if v <= n] m = len(G) m len(G) len G for i in range(m):
    cnt_all += insertionSort(A, n, G[i]) i range(m) range m cnt_all += insertionSort(A, n, G[i]) cnt_all insertionSort(A, n, G[i]) insertionSort A n G[i] G i print(m) print m print(*G) print *G G print(cnt_all) print cnt_all print(*A, sep='\n') print *A A sep='\n' sep '\n' cnt_all = 0 0 cnt_all cnt_all += insertionSort(A, n, G[i]) insertionSort(A, n, G[i]) cnt_all m = len(G) len(G) m A = [] [] A G = [int((3**i-1)/2)for i in range(17,0,-1)] [int((3**i-1)/2)for i in range(17,0,-1)] G n = int(input()) int(input()) n def insertionSort(A, n, g):
    cnt_local = 0
    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_local += 1
        A[j+g] = v
    return cnt_local def insertionSort(A, n, g):
    cnt_local = 0
    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_local += 1
        A[j+g] = v
    return cnt_local insertionSort G = [v for v in G if v <= n] [v for v in G if v <= n] G
def insertionSort(A, n, g):
    cnt_local = 0
    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_local += 1
        A[j+g] = v
    return cnt_local

cnt_all = 0
n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))

G = [int((3**i-1)/2)for i in range(17,0,-1)]
G = [v for v in G if v <= n]
m = len(G)
for i in range(m):
    cnt_all += insertionSort(A, n, G[i])

print(m)
print(*G)
print(cnt_all)
print(*A, sep='\n')

