from math import floor
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:
            A[j+g]=A[j]
            j-=g
            cnt+=1
        A[j+g]=v
        
def shellSort(A,n):
    global G
    for i in G:
        insertionSort(A,n,i)
cnt=0
N=int(input())
A=[int(input())for i in range(N)]
G=[1]
for i in range(99):
    if N<1+3*G[-1]:
        break
    G.append(1+3*G[-1])
G.reverse()
shellSort(A,N)
print(len(G)," ".join(list(map(str,G))),cnt,sep="\n")
for i in A:
    print(i) from math import floor 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:
            A[j+g]=A[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:
            A[j+g]=A[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-=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-=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):
    global G
    for i in G:
        insertionSort(A,n,i) shellSort global G for i in G:
        insertionSort(A,n,i) i G insertionSort(A,n,i) insertionSort A n i A A n n cnt=0 cnt 0 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)] G=[1] G [1] 1 for i in range(99):
    if N<1+3*G[-1]:
        break
    G.append(1+3*G[-1]) i range(99) range 99 if N<1+3*G[-1]:
        break
     N<1+3*G[-1] N 1+3*G[-1] 1 3*G[-1] 3 G[-1] G -1 break G.append(1+3*G[-1]) G.append G append 1+3*G[-1] 1 3*G[-1] 3 G[-1] G -1 G.reverse() G.reverse G reverse shellSort(A,N) shellSort A N print(len(G)," ".join(list(map(str,G))),cnt,sep="\n") print len(G) len G " ".join(list(map(str,G))) " ".join " " join list(map(str,G)) list map(str,G) map str G cnt sep="\n" sep "\n" for i in A:
    print(i) i A print(i) print i cnt=0 0 cnt A=[int(input())for i in range(N)] [int(input())for i in range(N)] A def shellSort(A,n):
    global G
    for i in G:
        insertionSort(A,n,i) def shellSort(A,n):
    global G
    for i in G:
        insertionSort(A,n,i) shellSort G=[1] [1] G 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:
            A[j+g]=A[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:
            A[j+g]=A[j]
            j-=g
            cnt+=1
        A[j+g]=v
         insertionSort N=int(input()) int(input()) N
from math import floor
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:
            A[j+g]=A[j]
            j-=g
            cnt+=1
        A[j+g]=v
        
def shellSort(A,n):
    global G
    for i in G:
        insertionSort(A,n,i)
cnt=0
N=int(input())
A=[int(input())for i in range(N)]
G=[1]
for i in range(99):
    if N<1+3*G[-1]:
        break
    G.append(1+3*G[-1])
G.reverse()
shellSort(A,N)
print(len(G)," ".join(list(map(str,G))),cnt,sep="\n")
for i in A:
    print(i)
