import math
def InsertionSort(A, N, g):
    global cnt
    for i in range(g, N):
        key = A[i]
        j = i-g
        while j >= 0 and A[j] > key:
            A[j+g] = A[j]
            j = j-g
            cnt += 1    
        A[j+g] = key
    return A

def ShellSort(A, N):
    G = []
    i = 1
    while True:
        if  3**i -1 > N*2:
            break
        G.insert(0, int((3**i-1)/2))
        i += 1


    for i in range(len(G)):
        InsertionSort(A, N, G[i])
    return G

N = int(input())
A = []
cnt = 0
for i in range(N):
    A.append(int(input()))
ShellSort(A,N)
print(len(ShellSort(A,N)))
print(*ShellSort(A,N))
print(cnt)
print(*A, sep='\n') import math math def InsertionSort(A, N, g):
    global cnt
    for i in range(g, N):
        key = A[i]
        j = i-g
        while j >= 0 and A[j] > key:
            A[j+g] = A[j]
            j = j-g
            cnt += 1    
        A[j+g] = key
    return A InsertionSort global cnt for i in range(g, N):
        key = A[i]
        j = i-g
        while j >= 0 and A[j] > key:
            A[j+g] = A[j]
            j = j-g
            cnt += 1    
        A[j+g] = key
     i range(g, N) range g N key = A[i] key A[i] A i j = i-g j i-g i g while j >= 0 and A[j] > key:
            A[j+g] = A[j]
            j = j-g
            cnt += 1    
         j >= 0 and A[j] > key j >= 0 j 0 A[j] > key A[j] A j key 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] = key A[j+g] A j+g j g key return A A A A N N g g def ShellSort(A, N):
    G = []
    i = 1
    while True:
        if  3**i -1 > N*2:
            break
        G.insert(0, int((3**i-1)/2))
        i += 1


    for i in range(len(G)):
        InsertionSort(A, N, G[i])
    return G ShellSort G = [] G [] i = 1 i 1 while True:
        if  3**i -1 > N*2:
            break
        G.insert(0, int((3**i-1)/2))
        i += 1


     True if  3**i -1 > N*2:
            break
         3**i -1 > N*2 3**i -1 3**i 3 i 1 N*2 N 2 break G.insert(0, int((3**i-1)/2)) G.insert G insert 0 int((3**i-1)/2) int (3**i-1)/2 3**i-1 3**i 3 i 1 2 i += 1 i 1 for i in range(len(G)):
        InsertionSort(A, N, G[i])
     i range(len(G)) range len(G) len G InsertionSort(A, N, G[i]) InsertionSort A N G[i] G i return G G A A N N N = int(input()) N int(input()) int input() input A = [] A [] cnt = 0 cnt 0 for i in range(N):
    A.append(int(input())) i range(N) range N A.append(int(input())) A.append A append int(input()) int input() input ShellSort(A,N) ShellSort A N print(len(ShellSort(A,N))) print len(ShellSort(A,N)) len ShellSort(A,N) ShellSort A N print(*ShellSort(A,N)) print *ShellSort(A,N) ShellSort(A,N) ShellSort A N print(cnt) print cnt print(*A, sep='\n') print *A A sep='\n' sep '\n' A = [] [] A def ShellSort(A, N):
    G = []
    i = 1
    while True:
        if  3**i -1 > N*2:
            break
        G.insert(0, int((3**i-1)/2))
        i += 1


    for i in range(len(G)):
        InsertionSort(A, N, G[i])
    return G def ShellSort(A, N):
    G = []
    i = 1
    while True:
        if  3**i -1 > N*2:
            break
        G.insert(0, int((3**i-1)/2))
        i += 1


    for i in range(len(G)):
        InsertionSort(A, N, G[i])
    return G ShellSort def InsertionSort(A, N, g):
    global cnt
    for i in range(g, N):
        key = A[i]
        j = i-g
        while j >= 0 and A[j] > key:
            A[j+g] = A[j]
            j = j-g
            cnt += 1    
        A[j+g] = key
    return A def InsertionSort(A, N, g):
    global cnt
    for i in range(g, N):
        key = A[i]
        j = i-g
        while j >= 0 and A[j] > key:
            A[j+g] = A[j]
            j = j-g
            cnt += 1    
        A[j+g] = key
    return A InsertionSort N = int(input()) int(input()) N cnt = 0 0 cnt
import math
def InsertionSort(A, N, g):
    global cnt
    for i in range(g, N):
        key = A[i]
        j = i-g
        while j >= 0 and A[j] > key:
            A[j+g] = A[j]
            j = j-g
            cnt += 1    
        A[j+g] = key
    return A

def ShellSort(A, N):
    G = []
    i = 1
    while True:
        if  3**i -1 > N*2:
            break
        G.insert(0, int((3**i-1)/2))
        i += 1


    for i in range(len(G)):
        InsertionSort(A, N, G[i])
    return G

N = int(input())
A = []
cnt = 0
for i in range(N):
    A.append(int(input()))
ShellSort(A,N)
print(len(ShellSort(A,N)))
print(*ShellSort(A,N))
print(cnt)
print(*A, sep='\n')