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

def insertion_sort(ar,num,g):
    count=0
    for i in range(g,num):
        v=ar[i]
        j=i-g
        while j>=0 and ar[j]>v:
            ar[j+g]=ar[j]
            j=j-g
            count+=1
        ar[j+g]=v
    return count

def shell_sort(AR,num):
    count=0
    m = math.floor(math.log(2 * n + 1) / math.log(3))
    print(m)
    G = [0 for i in range(m)]   
    G[0] = 1
    for i in range(1, m):
        G[i] = 3 * G[i - 1] + 1
    G.reverse()
    print(*G)
   
    for i in range(m):
        count+= insertion_sort(A, n, G[i])
    print(count)


shell_sort(A,n)
for i in A:
        print(i)
     import math math 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)] def insertion_sort(ar,num,g):
    count=0
    for i in range(g,num):
        v=ar[i]
        j=i-g
        while j>=0 and ar[j]>v:
            ar[j+g]=ar[j]
            j=j-g
            count+=1
        ar[j+g]=v
    return count insertion_sort count=0 count 0 for i in range(g,num):
        v=ar[i]
        j=i-g
        while j>=0 and ar[j]>v:
            ar[j+g]=ar[j]
            j=j-g
            count+=1
        ar[j+g]=v
     i range(g,num) range g num v=ar[i] v ar[i] ar i j=i-g j i-g i g while j>=0 and ar[j]>v:
            ar[j+g]=ar[j]
            j=j-g
            count+=1
         j>=0 and ar[j]>v j>=0 j 0 ar[j]>v ar[j] ar j v ar[j+g]=ar[j] ar[j+g] ar j+g j g ar[j] ar j j=j-g j j-g j g count+=1 count 1 ar[j+g]=v ar[j+g] ar j+g j g v return count count ar ar num num g g def shell_sort(AR,num):
    count=0
    m = math.floor(math.log(2 * n + 1) / math.log(3))
    print(m)
    G = [0 for i in range(m)]   
    G[0] = 1
    for i in range(1, m):
        G[i] = 3 * G[i - 1] + 1
    G.reverse()
    print(*G)
   
    for i in range(m):
        count+= insertion_sort(A, n, G[i])
    print(count) shell_sort count=0 count 0 m = math.floor(math.log(2 * n + 1) / math.log(3)) m math.floor(math.log(2 * n + 1) / math.log(3)) math.floor math floor math.log(2 * n + 1) / math.log(3) math.log(2 * n + 1) math.log math log 2 * n + 1 2 * n 2 n 1 math.log(3) math.log math log 3 print(m) print m 0 for i in range(m) for i in range(m) i range(m) range m for i in range(m) 0 G = [0 for i in range(m)] G [0 for i in range(m)] G[0] = 1 G[0] G 0 1 for i in range(1, m):
        G[i] = 3 * G[i - 1] + 1
     i range(1, m) range 1 m G[i] = 3 * G[i - 1] + 1 G[i] G i 3 * G[i - 1] + 1 3 * G[i - 1] 3 G[i - 1] G i - 1 i 1 1 G.reverse() G.reverse G reverse print(*G) print *G G for i in range(m):
        count+= insertion_sort(A, n, G[i])
     i range(m) range m count+= insertion_sort(A, n, G[i]) count insertion_sort(A, n, G[i]) insertion_sort A n G[i] G i print(count) print count AR AR num num shell_sort(A,n) shell_sort A n for i in A:
        print(i)
     i A print(i) print i n=int(input()) int(input()) n A=[int(input()) for i in range(n)] [int(input()) for i in range(n)] A def shell_sort(AR,num):
    count=0
    m = math.floor(math.log(2 * n + 1) / math.log(3))
    print(m)
    G = [0 for i in range(m)]   
    G[0] = 1
    for i in range(1, m):
        G[i] = 3 * G[i - 1] + 1
    G.reverse()
    print(*G)
   
    for i in range(m):
        count+= insertion_sort(A, n, G[i])
    print(count) def shell_sort(AR,num):
    count=0
    m = math.floor(math.log(2 * n + 1) / math.log(3))
    print(m)
    G = [0 for i in range(m)]   
    G[0] = 1
    for i in range(1, m):
        G[i] = 3 * G[i - 1] + 1
    G.reverse()
    print(*G)
   
    for i in range(m):
        count+= insertion_sort(A, n, G[i])
    print(count) shell_sort def insertion_sort(ar,num,g):
    count=0
    for i in range(g,num):
        v=ar[i]
        j=i-g
        while j>=0 and ar[j]>v:
            ar[j+g]=ar[j]
            j=j-g
            count+=1
        ar[j+g]=v
    return count def insertion_sort(ar,num,g):
    count=0
    for i in range(g,num):
        v=ar[i]
        j=i-g
        while j>=0 and ar[j]>v:
            ar[j+g]=ar[j]
            j=j-g
            count+=1
        ar[j+g]=v
    return count insertion_sort
import math
n=int(input())
A=[int(input()) for i in range(n)]

def insertion_sort(ar,num,g):
    count=0
    for i in range(g,num):
        v=ar[i]
        j=i-g
        while j>=0 and ar[j]>v:
            ar[j+g]=ar[j]
            j=j-g
            count+=1
        ar[j+g]=v
    return count

def shell_sort(AR,num):
    count=0
    m = math.floor(math.log(2 * n + 1) / math.log(3))
    print(m)
    G = [0 for i in range(m)]   
    G[0] = 1
    for i in range(1, m):
        G[i] = 3 * G[i - 1] + 1
    G.reverse()
    print(*G)
   
    for i in range(m):
        count+= insertion_sort(A, n, G[i])
    print(count)


shell_sort(A,n)
for i in A:
        print(i)
    