def InsertSort(A, n, g, 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
    return cnt
        
def ShellSort(A, n):
    cnt = 0
    G = [1]
    h = G[0]
    while True:
        h = h*3 + 1
        if h > n:
            break
        G.append(h)
    print(len(G))
    print(' '.join(reversed(list(map(str, G)))))
    for h in reversed(G):
        cnt = InsertSort(A, n, h, cnt)
    print(cnt)
            
n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))
    
ShellSort(A, n)

for num in A:
    print(num) def InsertSort(A, n, g, 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
    return cnt
         InsertSort 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 return cnt cnt A A n n g g cnt cnt def ShellSort(A, n):
    cnt = 0
    G = [1]
    h = G[0]
    while True:
        h = h*3 + 1
        if h > n:
            break
        G.append(h)
    print(len(G))
    print(' '.join(reversed(list(map(str, G)))))
    for h in reversed(G):
        cnt = InsertSort(A, n, h, cnt)
    print(cnt)
             ShellSort cnt = 0 cnt 0 G = [1] G [1] 1 h = G[0] h G[0] G 0 while True:
        h = h*3 + 1
        if h > n:
            break
        G.append(h)
     True h = h*3 + 1 h h*3 + 1 h*3 h 3 1 if h > n:
            break
         h > n h n break G.append(h) G.append G append h print(len(G)) print len(G) len G print(' '.join(reversed(list(map(str, G))))) print ' '.join(reversed(list(map(str, G)))) ' '.join ' ' join reversed(list(map(str, G))) reversed list(map(str, G)) list map(str, G) map str G for h in reversed(G):
        cnt = InsertSort(A, n, h, cnt)
     h reversed(G) reversed G cnt = InsertSort(A, n, h, cnt) cnt InsertSort(A, n, h, cnt) InsertSort A n h cnt print(cnt) print cnt A A n n n = int(input()) n int(input()) int input() input A = [] A [] for _ in range(n):
    A.append(int(input()))
     _ range(n) range n A.append(int(input())) A.append A append int(input()) int input() input ShellSort(A, n) ShellSort A n for num in A:
    print(num) num A print(num) print num def InsertSort(A, n, g, 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
    return cnt
         def InsertSort(A, n, g, 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
    return cnt
         InsertSort n = int(input()) int(input()) n A = [] [] A def ShellSort(A, n):
    cnt = 0
    G = [1]
    h = G[0]
    while True:
        h = h*3 + 1
        if h > n:
            break
        G.append(h)
    print(len(G))
    print(' '.join(reversed(list(map(str, G)))))
    for h in reversed(G):
        cnt = InsertSort(A, n, h, cnt)
    print(cnt)
             def ShellSort(A, n):
    cnt = 0
    G = [1]
    h = G[0]
    while True:
        h = h*3 + 1
        if h > n:
            break
        G.append(h)
    print(len(G))
    print(' '.join(reversed(list(map(str, G)))))
    for h in reversed(G):
        cnt = InsertSort(A, n, h, cnt)
    print(cnt)
             ShellSort
def InsertSort(A, n, g, 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
    return cnt
        
def ShellSort(A, n):
    cnt = 0
    G = [1]
    h = G[0]
    while True:
        h = h*3 + 1
        if h > n:
            break
        G.append(h)
    print(len(G))
    print(' '.join(reversed(list(map(str, G)))))
    for h in reversed(G):
        cnt = InsertSort(A, n, h, cnt)
    print(cnt)
            
n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))
    
ShellSort(A, n)

for num in A:
    print(num)
