import math

def insert_sort(A, n, g):
    cnt = 0
    for i in range(g, n):
        j = i - g
        v = A[i]
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v
    return cnt

def shell_sort(A, n):
    cnt = 0
    
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = h*3+1
    
    G.reverse()
    
    print(len(G))
    print(*G)
        
    for g in G:
        cnt += insert_sort(A, n, g)
    return cnt

N = int(input())
A = [int(input()) for _ in range(N)]

cnt = shell_sort(A, N)

print(cnt)

for a in A:
    print(a)
 import math math def insert_sort(A, n, g):
    cnt = 0
    for i in range(g, n):
        j = i - g
        v = A[i]
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v
    return cnt insert_sort cnt = 0 cnt 0 for i in range(g, n):
        j = i - g
        v = A[i]
        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 j = i - g j i - g i g v = A[i] v A[i] A i 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 return cnt cnt A A n n g g def shell_sort(A, n):
    cnt = 0
    
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = h*3+1
    
    G.reverse()
    
    print(len(G))
    print(*G)
        
    for g in G:
        cnt += insert_sort(A, n, g)
    return cnt shell_sort cnt = 0 cnt 0 G = [] G [] h = 1 h 1 while h <= n:
        G.append(h)
        h = h*3+1
    
     h <= n h n G.append(h) G.append G append h h = h*3+1 h h*3+1 h*3 h 3 1 G.reverse() G.reverse G reverse print(len(G)) print len(G) len G print(*G) print *G G for g in G:
        cnt += insert_sort(A, n, g)
     g G cnt += insert_sort(A, n, g) cnt insert_sort(A, n, g) insert_sort A n g return cnt cnt A A n n 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)] cnt = shell_sort(A, N) cnt shell_sort(A, N) shell_sort A N print(cnt) print cnt for a in A:
    print(a) a A print(a) print a def insert_sort(A, n, g):
    cnt = 0
    for i in range(g, n):
        j = i - g
        v = A[i]
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v
    return cnt def insert_sort(A, n, g):
    cnt = 0
    for i in range(g, n):
        j = i - g
        v = A[i]
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v
    return cnt insert_sort cnt = shell_sort(A, N) shell_sort(A, N) cnt A = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] A def shell_sort(A, n):
    cnt = 0
    
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = h*3+1
    
    G.reverse()
    
    print(len(G))
    print(*G)
        
    for g in G:
        cnt += insert_sort(A, n, g)
    return cnt def shell_sort(A, n):
    cnt = 0
    
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = h*3+1
    
    G.reverse()
    
    print(len(G))
    print(*G)
        
    for g in G:
        cnt += insert_sort(A, n, g)
    return cnt shell_sort N = int(input()) int(input()) N
import math

def insert_sort(A, n, g):
    cnt = 0
    for i in range(g, n):
        j = i - g
        v = A[i]
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v
    return cnt

def shell_sort(A, n):
    cnt = 0
    
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = h*3+1
    
    G.reverse()
    
    print(len(G))
    print(*G)
        
    for g in G:
        cnt += insert_sort(A, n, g)
    return cnt

N = int(input())
A = [int(input()) for _ in range(N)]

cnt = shell_sort(A, N)

print(cnt)

for a in A:
    print(a)

