import copy as cp

n = int(input())
A = list()
for i in range(n):
    A.append(int(input()))

count = 0
#print(A)
def insertionsort(A,n,g):
    global count
    for i in range(g,n):
        v = A[i]
        j = i-g
        while (j >= 0 and A[j] > v):
            A[j+g] = A[j]
            A[j] = v
            j = j - g
            v = A[j+g]
            count += 1

#decision of m and g
G = list()
G.append(int(1))
i = 0
while (G[i] <= n):
    G.append(3*G[i] + 1)
    i += 1
del G[-1]
G.reverse()
m = len(G)
#print(G,m)


#shellsort

for i in range(m):
    insertionsort(A,n,G[i])

#output
print(m)
for k in range(m-1):
    print(str(G[k])+" ",end = "")
print(str(G[m-1]))
print(count)
for k in range(n):
    print(str(A[k]))
 import copy as cp copy n = int(input()) n int(input()) int input() input A = list() A list() list for i in range(n):
    A.append(int(input())) i range(n) range n A.append(int(input())) A.append A append int(input()) int input() input count = 0 count 0 def insertionsort(A,n,g):
    global count
    for i in range(g,n):
        v = A[i]
        j = i-g
        while (j >= 0 and A[j] > v):
            A[j+g] = A[j]
            A[j] = v
            j = j - g
            v = A[j+g]
            count += 1

#decision of m and g insertionsort global count for i in range(g,n):
        v = A[i]
        j = i-g
        while (j >= 0 and A[j] > v):
            A[j+g] = A[j]
            A[j] = v
            j = j - g
            v = A[j+g]
            count += 1

#decision of m and g 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]
            A[j] = v
            j = j - g
            v = A[j+g]
            count += 1

#decision of m and g 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 A[j] = v A[j] A j v j = j - g j j - g j g v = A[j+g] v A[j+g] A j+g j g count += 1 count 1 A A n n g g G = list() G list() list G.append(int(1)) G.append G append int(1) int 1 i = 0 i 0 while (G[i] <= n):
    G.append(3*G[i] + 1)
    i += 1 G[i] <= n G[i] G i n G.append(3*G[i] + 1) G.append G append 3*G[i] + 1 3*G[i] 3 G[i] G i 1 i += 1 i 1 del G[-1] G[-1] G -1 G.reverse() G.reverse G reverse m = len(G) m len(G) len G for i in range(m):
    insertionsort(A,n,G[i])

#output i range(m) range m insertionsort(A,n,G[i]) insertionsort A n G[i] G i print(m) print m for k in range(m-1):
    print(str(G[k])+" ",end = "") k range(m-1) range m-1 m 1 print(str(G[k])+" ",end = "") print str(G[k])+" " str(G[k]) str G[k] G k " " end = "" end "" print(str(G[m-1])) print str(G[m-1]) str G[m-1] G m-1 m 1 print(count) print count for k in range(n):
    print(str(A[k])) k range(n) range n print(str(A[k])) print str(A[k]) str A[k] A k m = len(G) len(G) m def insertionsort(A,n,g):
    global count
    for i in range(g,n):
        v = A[i]
        j = i-g
        while (j >= 0 and A[j] > v):
            A[j+g] = A[j]
            A[j] = v
            j = j - g
            v = A[j+g]
            count += 1

#decision of m and g def insertionsort(A,n,g):
    global count
    for i in range(g,n):
        v = A[i]
        j = i-g
        while (j >= 0 and A[j] > v):
            A[j+g] = A[j]
            A[j] = v
            j = j - g
            v = A[j+g]
            count += 1

#decision of m and g insertionsort G = list() list() G i = 0 0 i i += 1 1 i count = 0 0 count n = int(input()) int(input()) n A = list() list() A
import copy as cp

n = int(input())
A = list()
for i in range(n):
    A.append(int(input()))

count = 0
#print(A)
def insertionsort(A,n,g):
    global count
    for i in range(g,n):
        v = A[i]
        j = i-g
        while (j >= 0 and A[j] > v):
            A[j+g] = A[j]
            A[j] = v
            j = j - g
            v = A[j+g]
            count += 1

#decision of m and g
G = list()
G.append(int(1))
i = 0
while (G[i] <= n):
    G.append(3*G[i] + 1)
    i += 1
del G[-1]
G.reverse()
m = len(G)
#print(G,m)


#shellsort

for i in range(m):
    insertionsort(A,n,G[i])

#output
print(m)
for k in range(m-1):
    print(str(G[k])+" ",end = "")
print(str(G[m-1]))
print(count)
for k in range(n):
    print(str(A[k]))

