cnt=0
def insertion_sort(A, g):
    global cnt
    N=len(A)
    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 shell_sort(A):
    G=[]
    i=1
    while i<=len(A):
        G.append(i)
        i=i*3+1
    G=G[::-1]
    for g in G:
        insertion_sort(A, g)
    return G
N=int(input())
A=[int(input()) for _ in range(N)]
G=shell_sort(A)
print(len(G))
print(*G)
print(cnt)
for a in A:
    print(a) cnt=0 cnt 0 def insertion_sort(A, g):
    global cnt
    N=len(A)
    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 insertion_sort global cnt N=len(A) N len(A) len A 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 g g def shell_sort(A):
    G=[]
    i=1
    while i<=len(A):
        G.append(i)
        i=i*3+1
    G=G[::-1]
    for g in G:
        insertion_sort(A, g)
    return G shell_sort G=[] G [] i=1 i 1 while i<=len(A):
        G.append(i)
        i=i*3+1
     i<=len(A) i len(A) len A G.append(i) G.append G append i i=i*3+1 i i*3+1 i*3 i 3 1 G=G[::-1] G G[::-1] G ::-1 -1 for g in G:
        insertion_sort(A, g)
     g G insertion_sort(A, g) insertion_sort A g return G G A A N=int(input()) N int(input()) int input() input int(input()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(input()) int input() input A=[int(input()) for _ in range(N)] A [int(input()) for _ in range(N)] G=shell_sort(A) G shell_sort(A) shell_sort A print(len(G)) print len(G) len G print(*G) print *G G print(cnt) print cnt for a in A:
    print(a) a A print(a) print a def insertion_sort(A, g):
    global cnt
    N=len(A)
    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 insertion_sort(A, g):
    global cnt
    N=len(A)
    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 insertion_sort def shell_sort(A):
    G=[]
    i=1
    while i<=len(A):
        G.append(i)
        i=i*3+1
    G=G[::-1]
    for g in G:
        insertion_sort(A, g)
    return G def shell_sort(A):
    G=[]
    i=1
    while i<=len(A):
        G.append(i)
        i=i*3+1
    G=G[::-1]
    for g in G:
        insertion_sort(A, g)
    return G shell_sort cnt=0 0 cnt A=[int(input()) for _ in range(N)] [int(input()) for _ in range(N)] A N=int(input()) int(input()) N G=shell_sort(A) shell_sort(A) G
cnt=0
def insertion_sort(A, g):
    global cnt
    N=len(A)
    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 shell_sort(A):
    G=[]
    i=1
    while i<=len(A):
        G.append(i)
        i=i*3+1
    G=G[::-1]
    for g in G:
        insertion_sort(A, g)
    return G
N=int(input())
A=[int(input()) for _ in range(N)]
G=shell_sort(A)
print(len(G))
print(*G)
print(cnt)
for a in A:
    print(a)
