# def insertionsort(A,n,g):
#     global 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 = j - g
#             cnt += 1
#         A[j+g] = v

def insertionsort(A,n,g):
    global cnt
    for i in range(g,n):
        right = i
        left = i - g
        while left >= 0 and A[left] > A[right]:
            A[right],A[left] = A[left],A[right]
            right = left
            left -= g
            cnt += 1

def shellsort(A,n):
    G = [1]
    x = 0
    while G[x]*3 + 1 <= n:
        G.append(G[x]*3 + 1)
        x += 1

    G = G[::-1]
    for i in range(len(G)):
        insertionsort(A,n,G[i])

    return A,G,cnt


if __name__ == '__main__':
    import math
    n = int(input())
    A = []
    cnt = 0
    for i in range(n):
        x = int(input())
        A.append(x)
    ans,G,cnt = shellsort(A,n)

    #answer
    print(len(G))
    for i in range(len(G)):
        if i == len(G) - 1:
            print(G[i])
        else:
            print(G[i],end = " ")
    print(cnt)
    for i in range(n):
        print(ans[i])
 def insertionsort(A,n,g):
    global cnt
    for i in range(g,n):
        right = i
        left = i - g
        while left >= 0 and A[left] > A[right]:
            A[right],A[left] = A[left],A[right]
            right = left
            left -= g
            cnt += 1 insertionsort global cnt for i in range(g,n):
        right = i
        left = i - g
        while left >= 0 and A[left] > A[right]:
            A[right],A[left] = A[left],A[right]
            right = left
            left -= g
            cnt += 1 i range(g,n) range g n right = i right i left = i - g left i - g i g while left >= 0 and A[left] > A[right]:
            A[right],A[left] = A[left],A[right]
            right = left
            left -= g
            cnt += 1 left >= 0 and A[left] > A[right] left >= 0 left 0 A[left] > A[right] A[left] A left A[right] A right A[right],A[left] = A[left],A[right] A[right] A right A[left] A left A[left] A left A[right] A right right = left right left left -= g left g cnt += 1 cnt 1 A A n n g g def shellsort(A,n):
    G = [1]
    x = 0
    while G[x]*3 + 1 <= n:
        G.append(G[x]*3 + 1)
        x += 1

    G = G[::-1]
    for i in range(len(G)):
        insertionsort(A,n,G[i])

    return A,G,cnt shellsort G = [1] G [1] 1 x = 0 x 0 while G[x]*3 + 1 <= n:
        G.append(G[x]*3 + 1)
        x += 1

     G[x]*3 + 1 <= n G[x]*3 + 1 G[x]*3 G[x] G x 3 1 n G.append(G[x]*3 + 1) G.append G append G[x]*3 + 1 G[x]*3 G[x] G x 3 1 x += 1 x 1 G = G[::-1] G G[::-1] G ::-1 -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 A,G,cnt return A,G,cnt A G cnt A A n n if __name__ == '__main__':
    import math
    n = int(input())
    A = []
    cnt = 0
    for i in range(n):
        x = int(input())
        A.append(x)
    ans,G,cnt = shellsort(A,n)

    #answer
    print(len(G))
    for i in range(len(G)):
        if i == len(G) - 1:
            print(G[i])
        else:
            print(G[i],end = " ")
    print(cnt)
    for i in range(n):
        print(ans[i]) __name__ == '__main__' __name__ '__main__' import math math n = int(input()) n int(input()) int input() input A = [] A [] cnt = 0 cnt 0 for i in range(n):
        x = int(input())
        A.append(x)
     i range(n) range n x = int(input()) x int(input()) int input() input A.append(x) A.append A append x ans,G,cnt = shellsort(A,n) ans shellsort(A,n) shellsort A n G cnt print(len(G)) print len(G) len G for i in range(len(G)):
        if i == len(G) - 1:
            print(G[i])
        else:
            print(G[i],end = " ")
     i range(len(G)) range len(G) len G if i == len(G) - 1:
            print(G[i])
        else:
            print(G[i],end = " ")
     i == len(G) - 1 i len(G) - 1 len(G) len G 1 print(G[i]) print G[i] G i print(G[i],end = " ") print G[i] G i end = " " end " " print(cnt) print cnt for i in range(n):
        print(ans[i]) i range(n) range n print(ans[i]) print ans[i] ans i ans,G,cnt = shellsort(A,n) shellsort(A,n) ans G,cnt = shellsort(A,n) shellsort(A,n) G def shellsort(A,n):
    G = [1]
    x = 0
    while G[x]*3 + 1 <= n:
        G.append(G[x]*3 + 1)
        x += 1

    G = G[::-1]
    for i in range(len(G)):
        insertionsort(A,n,G[i])

    return A,G,cnt def shellsort(A,n):
    G = [1]
    x = 0
    while G[x]*3 + 1 <= n:
        G.append(G[x]*3 + 1)
        x += 1

    G = G[::-1]
    for i in range(len(G)):
        insertionsort(A,n,G[i])

    return A,G,cnt shellsort A = [] [] A cnt = 0 0 cnt def insertionsort(A,n,g):
    global cnt
    for i in range(g,n):
        right = i
        left = i - g
        while left >= 0 and A[left] > A[right]:
            A[right],A[left] = A[left],A[right]
            right = left
            left -= g
            cnt += 1 def insertionsort(A,n,g):
    global cnt
    for i in range(g,n):
        right = i
        left = i - g
        while left >= 0 and A[left] > A[right]:
            A[right],A[left] = A[left],A[right]
            right = left
            left -= g
            cnt += 1 insertionsort cnt = shellsort(A,n) shellsort(A,n) cnt n = int(input()) int(input()) n x = int(input()) int(input()) x
# def insertionsort(A,n,g):
#     global 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 = j - g
#             cnt += 1
#         A[j+g] = v

def insertionsort(A,n,g):
    global cnt
    for i in range(g,n):
        right = i
        left = i - g
        while left >= 0 and A[left] > A[right]:
            A[right],A[left] = A[left],A[right]
            right = left
            left -= g
            cnt += 1

def shellsort(A,n):
    G = [1]
    x = 0
    while G[x]*3 + 1 <= n:
        G.append(G[x]*3 + 1)
        x += 1

    G = G[::-1]
    for i in range(len(G)):
        insertionsort(A,n,G[i])

    return A,G,cnt


if __name__ == '__main__':
    import math
    n = int(input())
    A = []
    cnt = 0
    for i in range(n):
        x = int(input())
        A.append(x)
    ans,G,cnt = shellsort(A,n)

    #answer
    print(len(G))
    for i in range(len(G)):
        if i == len(G) - 1:
            print(G[i])
        else:
            print(G[i],end = " ")
    print(cnt)
    for i in range(n):
        print(ans[i])

