#coding: UTF-8

cnt = 0

def SelectionSort(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 ShellSort(A,N):
    G = [None] * 20
    cnt = 0
    
    for i in range(1,21):
        G[i - 1] = int(((3 ** i) - 1) / 2)
    for i in range(1,21):
        if N < G[i - 1]:
            m = i - 2
            break
    for i in range(m,-1,-1):
        SelectionSort(A,N,G[i])
    
    print(str(m+1))
    for i in range(m,0,- 1):
        print(str(G[i]) + " ", end = "")
    print(G[0])


N = int(input())
A = [None] * N
for i in range(N):
    A[i] = int(input())


ShellSort(A,N)

print(cnt)
for i in range(N):
    print(A[i]) cnt = 0 cnt 0 def SelectionSort(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
         SelectionSort 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 ShellSort(A,N):
    G = [None] * 20
    cnt = 0
    
    for i in range(1,21):
        G[i - 1] = int(((3 ** i) - 1) / 2)
    for i in range(1,21):
        if N < G[i - 1]:
            m = i - 2
            break
    for i in range(m,-1,-1):
        SelectionSort(A,N,G[i])
    
    print(str(m+1))
    for i in range(m,0,- 1):
        print(str(G[i]) + " ", end = "")
    print(G[0]) ShellSort G = [None] * 20 G [None] * 20 [None] None 20 cnt = 0 cnt 0 for i in range(1,21):
        G[i - 1] = int(((3 ** i) - 1) / 2)
     i range(1,21) range 1 21 G[i - 1] = int(((3 ** i) - 1) / 2) G[i - 1] G i - 1 i 1 int(((3 ** i) - 1) / 2) int ((3 ** i) - 1) / 2 (3 ** i) - 1 3 ** i 3 i 1 2 for i in range(1,21):
        if N < G[i - 1]:
            m = i - 2
            break
     i range(1,21) range 1 21 if N < G[i - 1]:
            m = i - 2
            break
     N < G[i - 1] N G[i - 1] G i - 1 i 1 m = i - 2 m i - 2 i 2 break for i in range(m,-1,-1):
        SelectionSort(A,N,G[i])
    
     i range(m,-1,-1) range m -1 -1 SelectionSort(A,N,G[i]) SelectionSort A N G[i] G i print(str(m+1)) print str(m+1) str m+1 m 1 for i in range(m,0,- 1):
        print(str(G[i]) + " ", end = "")
     i range(m,0,- 1) range m 0 - 1 print(str(G[i]) + " ", end = "") print str(G[i]) + " " str(G[i]) str G[i] G i " " end = "" end "" print(G[0]) print G[0] G 0 A A N N N = int(input()) N int(input()) int input() input A = [None] * N A [None] * N [None] None N for i in range(N):
    A[i] = int(input()) i range(N) range N A[i] = int(input()) A[i] A i int(input()) int input() input ShellSort(A,N) ShellSort 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 def SelectionSort(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 SelectionSort(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
         SelectionSort def ShellSort(A,N):
    G = [None] * 20
    cnt = 0
    
    for i in range(1,21):
        G[i - 1] = int(((3 ** i) - 1) / 2)
    for i in range(1,21):
        if N < G[i - 1]:
            m = i - 2
            break
    for i in range(m,-1,-1):
        SelectionSort(A,N,G[i])
    
    print(str(m+1))
    for i in range(m,0,- 1):
        print(str(G[i]) + " ", end = "")
    print(G[0]) def ShellSort(A,N):
    G = [None] * 20
    cnt = 0
    
    for i in range(1,21):
        G[i - 1] = int(((3 ** i) - 1) / 2)
    for i in range(1,21):
        if N < G[i - 1]:
            m = i - 2
            break
    for i in range(m,-1,-1):
        SelectionSort(A,N,G[i])
    
    print(str(m+1))
    for i in range(m,0,- 1):
        print(str(G[i]) + " ", end = "")
    print(G[0]) ShellSort A = [None] * N [None] * N A N = int(input()) int(input()) N cnt = 0 0 cnt
#coding: UTF-8

cnt = 0

def SelectionSort(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 ShellSort(A,N):
    G = [None] * 20
    cnt = 0
    
    for i in range(1,21):
        G[i - 1] = int(((3 ** i) - 1) / 2)
    for i in range(1,21):
        if N < G[i - 1]:
            m = i - 2
            break
    for i in range(m,-1,-1):
        SelectionSort(A,N,G[i])
    
    print(str(m+1))
    for i in range(m,0,- 1):
        print(str(G[i]) + " ", end = "")
    print(G[0])


N = int(input())
A = [None] * N
for i in range(N):
    A[i] = int(input())


ShellSort(A,N)

print(cnt)
for i in range(N):
    print(A[i])