def shellSort(A):
    cnt = 0
    def insertionSort(A, g):
        nonlocal cnt
        for i in range(g,len(A)):
            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 = 0 
    G = [1]
    if len(A) > 1:
        while G[i] < len(A):
            G.append(3*G[i]+1)
            i += 1
        G = G[-2::-1]
    print(len(G))
    print(*G)
    for i in range(len(G)):
        insertionSort(A, G[i])
    return cnt

if __name__=='__main__':
    n = int(input()) 
    A = [int(input()) for _ in range(n)]
    print(shellSort(A))
    [print(ai) for ai in A] def shellSort(A):
    cnt = 0
    def insertionSort(A, g):
        nonlocal cnt
        for i in range(g,len(A)):
            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 = 0 
    G = [1]
    if len(A) > 1:
        while G[i] < len(A):
            G.append(3*G[i]+1)
            i += 1
        G = G[-2::-1]
    print(len(G))
    print(*G)
    for i in range(len(G)):
        insertionSort(A, G[i])
    return cnt shellSort cnt = 0 cnt 0 def insertionSort(A, g):
        nonlocal cnt
        for i in range(g,len(A)):
            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
     insertionSort nonlocal cnt for i in range(g,len(A)):
            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,len(A)) range g len(A) len A 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 g g i = 0 i 0 G = [1] G [1] 1 if len(A) > 1:
        while G[i] < len(A):
            G.append(3*G[i]+1)
            i += 1
        G = G[-2::-1]
     len(A) > 1 len(A) len A 1 while G[i] < len(A):
            G.append(3*G[i]+1)
            i += 1
         G[i] < len(A) G[i] G i len(A) len A G.append(3*G[i]+1) G.append G append 3*G[i]+1 3*G[i] 3 G[i] G i 1 i += 1 i 1 G = G[-2::-1] G G[-2::-1] G -2::-1 -2 -1 print(len(G)) print len(G) len G print(*G) print *G G for i in range(len(G)):
        insertionSort(A, G[i])
     i range(len(G)) range len(G) len G insertionSort(A, G[i]) insertionSort A G[i] G i return cnt cnt A A if __name__=='__main__':
    n = int(input()) 
    A = [int(input()) for _ in range(n)]
    print(shellSort(A))
    [print(ai) for ai in A] __name__=='__main__' __name__ '__main__' 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)] print(shellSort(A)) print shellSort(A) shellSort A print(ai) for ai in A for ai in A ai A for ai in A print(ai) print ai [print(ai) for ai in A] n = int(input()) int(input()) n A = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] A def shellSort(A):
    cnt = 0
    def insertionSort(A, g):
        nonlocal cnt
        for i in range(g,len(A)):
            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 = 0 
    G = [1]
    if len(A) > 1:
        while G[i] < len(A):
            G.append(3*G[i]+1)
            i += 1
        G = G[-2::-1]
    print(len(G))
    print(*G)
    for i in range(len(G)):
        insertionSort(A, G[i])
    return cnt def shellSort(A):
    cnt = 0
    def insertionSort(A, g):
        nonlocal cnt
        for i in range(g,len(A)):
            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 = 0 
    G = [1]
    if len(A) > 1:
        while G[i] < len(A):
            G.append(3*G[i]+1)
            i += 1
        G = G[-2::-1]
    print(len(G))
    print(*G)
    for i in range(len(G)):
        insertionSort(A, G[i])
    return cnt shellSort
def shellSort(A):
    cnt = 0
    def insertionSort(A, g):
        nonlocal cnt
        for i in range(g,len(A)):
            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 = 0 
    G = [1]
    if len(A) > 1:
        while G[i] < len(A):
            G.append(3*G[i]+1)
            i += 1
        G = G[-2::-1]
    print(len(G))
    print(*G)
    for i in range(len(G)):
        insertionSort(A, G[i])
    return cnt

if __name__=='__main__':
    n = int(input()) 
    A = [int(input()) for _ in range(n)]
    print(shellSort(A))
    [print(ai) for ai in A]