import math

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

def shellSort(A,n):
    cnt = 0
    m = round(math.log(len(A),2))+1 # 事前処理をやる回数
    print(m)
    G = [round(len(A)*((1/2)**(a+1))) for a in range(m)] # 事前処理時の、各回の間隔
    print(*G)
    for i in range(0,m):
        cnt += insertionSort(A,n,G[i])
    return cnt

n = int(input())
A = [int(input()) for a in range(n)]
print(shellSort(A,n))
for a in A:
    print(a)
 import math math def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i-g
        while j >= 0 and A[j] > v:
            A[j+g], A[j] = A[j],A[j+g]
            j -= g
            cnt += 1
        A[j+g] = v
    return cnt insertionSort cnt = 0 cnt 0 for i in range(g,n):
        v = A[i]
        j = i-g
        while j >= 0 and A[j] > v:
            A[j+g], A[j] = A[j],A[j+g]
            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] = A[j],A[j+g]
            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],A[j+g] A[j+g] A j+g j g A[j] A j A[j] A j A[j+g] A j+g j g 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 shellSort(A,n):
    cnt = 0
    m = round(math.log(len(A),2))+1 # 事前処理をやる回数
    print(m)
    G = [round(len(A)*((1/2)**(a+1))) for a in range(m)] # 事前処理時の、各回の間隔
    print(*G)
    for i in range(0,m):
        cnt += insertionSort(A,n,G[i])
    return cnt shellSort cnt = 0 cnt 0 m = round(math.log(len(A),2))+1 m round(math.log(len(A),2))+1 round(math.log(len(A),2)) round math.log(len(A),2) math.log math log len(A) len A 2 1 print(m) print m round(len(A)*((1/2)**(a+1))) for a in range(m) for a in range(m) a range(m) range m for a in range(m) round(len(A)*((1/2)**(a+1))) round len(A)*((1/2)**(a+1)) len(A) len A (1/2)**(a+1) 1/2 1 2 a+1 a 1 G = [round(len(A)*((1/2)**(a+1))) for a in range(m)] G [round(len(A)*((1/2)**(a+1))) for a in range(m)] print(*G) print *G G for i in range(0,m):
        cnt += insertionSort(A,n,G[i])
     i range(0,m) range 0 m cnt += insertionSort(A,n,G[i]) cnt insertionSort(A,n,G[i]) insertionSort A n G[i] G i return cnt cnt A A n n n = int(input()) n int(input()) int input() input int(input()) for a in range(n) for a in range(n) a range(n) range n for a in range(n) int(input()) int input() input A = [int(input()) for a in range(n)] A [int(input()) for a in range(n)] print(shellSort(A,n)) print shellSort(A,n) shellSort A n for a in A:
    print(a) a A print(a) print a def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i-g
        while j >= 0 and A[j] > v:
            A[j+g], A[j] = A[j],A[j+g]
            j -= g
            cnt += 1
        A[j+g] = v
    return cnt def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i-g
        while j >= 0 and A[j] > v:
            A[j+g], A[j] = A[j],A[j+g]
            j -= g
            cnt += 1
        A[j+g] = v
    return cnt insertionSort n = int(input()) int(input()) n def shellSort(A,n):
    cnt = 0
    m = round(math.log(len(A),2))+1 # 事前処理をやる回数
    print(m)
    G = [round(len(A)*((1/2)**(a+1))) for a in range(m)] # 事前処理時の、各回の間隔
    print(*G)
    for i in range(0,m):
        cnt += insertionSort(A,n,G[i])
    return cnt def shellSort(A,n):
    cnt = 0
    m = round(math.log(len(A),2))+1 # 事前処理をやる回数
    print(m)
    G = [round(len(A)*((1/2)**(a+1))) for a in range(m)] # 事前処理時の、各回の間隔
    print(*G)
    for i in range(0,m):
        cnt += insertionSort(A,n,G[i])
    return cnt shellSort A = [int(input()) for a in range(n)] [int(input()) for a in range(n)] A
import math

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

def shellSort(A,n):
    cnt = 0
    m = round(math.log(len(A),2))+1 # 事前処理をやる回数
    print(m)
    G = [round(len(A)*((1/2)**(a+1))) for a in range(m)] # 事前処理時の、各回の間隔
    print(*G)
    for i in range(0,m):
        cnt += insertionSort(A,n,G[i])
    return cnt

n = int(input())
A = [int(input()) for a in range(n)]
print(shellSort(A,n))
for a in A:
    print(a)

