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

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

for i in range(n):
    print(a[i])
