
cnt = 0
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:##後半の条件が付いていてもiを回すのでソートされる
            A[j+g] = A[j]
            j = j - g
            cnt+=1
            A[j+g] = v


def shellSort(A, n):
    tmp = 1
    G=[]
    while tmp<n:
        G.append(tmp)
        tmp*=3
        tmp+=1###なぜ要るのか分からないが
    G.reverse()
    for i in range(len(G)):
        insertionSort(A, n, G[i])

n = int(input())

G1=[]
tmp=1
while tmp<n:
    G1.append(tmp)
    tmp*=3
    tmp += 1
G1.reverse()
A1 =[int(input()) for _ in range(n)]
m = len(G1)
shellSort(A1, n)
print(max(m,1))
if G1:
    print(*G1)
else:
    print(1)
print(cnt)
for a in A1:
    print(a)


 cnt = 0 cnt 0 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:##後半の条件が付いていてもiを回すのでソートされる
            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:##後半の条件が付いていてもiを回すのでソートされる
            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:##後半の条件が付いていてもiを回すのでソートされる
            A[j+g] = A[j]
            j = j - g
            cnt+=1
            A[j+g] = v 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):
    tmp = 1
    G=[]
    while tmp<n:
        G.append(tmp)
        tmp*=3
        tmp+=1###なぜ要るのか分からないが
    G.reverse()
    for i in range(len(G)):
        insertionSort(A, n, G[i]) shellSort tmp = 1 tmp 1 G=[] G [] while tmp<n:
        G.append(tmp)
        tmp*=3
        tmp+=1###なぜ要るのか分からないが
     tmp<n tmp n G.append(tmp) G.append G append tmp tmp*=3 tmp 3 tmp+=1 tmp 1 G.reverse() G.reverse G reverse for i in range(len(G)):
        insertionSort(A, n, G[i]) i range(len(G)) range len(G) len G 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 G1=[] G1 [] tmp=1 tmp 1 while tmp<n:
    G1.append(tmp)
    tmp*=3
    tmp += 1 tmp<n tmp n G1.append(tmp) G1.append G1 append tmp tmp*=3 tmp 3 tmp += 1 tmp 1 G1.reverse() G1.reverse G1 reverse int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input A1 =[int(input()) for _ in range(n)] A1 [int(input()) for _ in range(n)] m = len(G1) m len(G1) len G1 shellSort(A1, n) shellSort A1 n print(max(m,1)) print max(m,1) max m 1 if G1:
    print(*G1)
else:
    print(1) G1 print(*G1) print *G1 G1 print(1) print 1 print(cnt) print cnt for a in A1:
    print(a) a A1 print(a) print a 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:##後半の条件が付いていてもiを回すのでソートされる
            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:##後半の条件が付いていてもiを回すのでソートされる
            A[j+g] = A[j]
            j = j - g
            cnt+=1
            A[j+g] = v insertionSort A1 =[int(input()) for _ in range(n)] [int(input()) for _ in range(n)] A1 tmp*=3 3 tmp tmp += 1 1 tmp def shellSort(A, n):
    tmp = 1
    G=[]
    while tmp<n:
        G.append(tmp)
        tmp*=3
        tmp+=1###なぜ要るのか分からないが
    G.reverse()
    for i in range(len(G)):
        insertionSort(A, n, G[i]) def shellSort(A, n):
    tmp = 1
    G=[]
    while tmp<n:
        G.append(tmp)
        tmp*=3
        tmp+=1###なぜ要るのか分からないが
    G.reverse()
    for i in range(len(G)):
        insertionSort(A, n, G[i]) shellSort G1=[] [] G1 tmp=1 1 tmp m = len(G1) len(G1) m cnt = 0 0 cnt n = int(input()) int(input()) n

cnt = 0
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:##後半の条件が付いていてもiを回すのでソートされる
            A[j+g] = A[j]
            j = j - g
            cnt+=1
            A[j+g] = v


def shellSort(A, n):
    tmp = 1
    G=[]
    while tmp<n:
        G.append(tmp)
        tmp*=3
        tmp+=1###なぜ要るのか分からないが
    G.reverse()
    for i in range(len(G)):
        insertionSort(A, n, G[i])

n = int(input())

G1=[]
tmp=1
while tmp<n:
    G1.append(tmp)
    tmp*=3
    tmp += 1
G1.reverse()
A1 =[int(input()) for _ in range(n)]
m = len(G1)
shellSort(A1, n)
print(max(m,1))
if G1:
    print(*G1)
else:
    print(1)
print(cnt)
for a in A1:
    print(a)



