def InsertionSort(A, n, g):
    c = 0
    for i in range(g, n):
        v, j = A[i], i - g
        while j>=0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            c += 1
        A[j+g] = v
    return c
def shellSort(n, A):
    cnt, G, gm = 0, [], 1
    while True:
        G = [gm] + G
        if gm*5+1 > n: break
        gm = 5*gm +1
    m = len(G)
    print(m)
    print(*G)
    for i in range(m):
        cnt += InsertionSort(A,n,G[i])
    return cnt


def ALDS1_2D():
    N = int(input())
    A = [int(input()) for n in range(N)]
    print(shellSort(N, A))
    for i in range(N):print(A[i])

if __name__ == '__main__':
    ALDS1_2D() def InsertionSort(A, n, g):
    c = 0
    for i in range(g, n):
        v, j = A[i], i - g
        while j>=0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            c += 1
        A[j+g] = v
    return c InsertionSort c = 0 c 0 for i in range(g, n):
        v, j = A[i], i - g
        while j>=0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            c += 1
        A[j+g] = v
     i range(g, n) range g n v, j = A[i], i - g v A[i] A i j i - g i g while j>=0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            c += 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 c += 1 c 1 A[j+g] = v A[j+g] A j+g j g v return c c A A n n g g def shellSort(n, A):
    cnt, G, gm = 0, [], 1
    while True:
        G = [gm] + G
        if gm*5+1 > n: break
        gm = 5*gm +1
    m = len(G)
    print(m)
    print(*G)
    for i in range(m):
        cnt += InsertionSort(A,n,G[i])
    return cnt shellSort cnt, G, gm = 0, [], 1 cnt 0 G [] gm 1 while True:
        G = [gm] + G
        if gm*5+1 > n: break
        gm = 5*gm +1
     True G = [gm] + G G [gm] + G [gm] gm G if gm*5+1 > n: break
         gm*5+1 > n gm*5+1 gm*5 gm 5 1 n gm = 5*gm +1 gm 5*gm +1 5*gm 5 gm 1 m = len(G) m len(G) len G print(m) print m print(*G) print *G G for i in range(m):
        cnt += InsertionSort(A,n,G[i])
     i range(m) range m cnt += InsertionSort(A,n,G[i]) cnt InsertionSort(A,n,G[i]) InsertionSort A n G[i] G i return cnt cnt n n A A def ALDS1_2D():
    N = int(input())
    A = [int(input()) for n in range(N)]
    print(shellSort(N, A))
    for i in range(N):print(A[i]) ALDS1_2D N = int(input()) N int(input()) int input() input int(input()) for n in range(N) for n in range(N) n range(N) range N for n in range(N) int(input()) int input() input A = [int(input()) for n in range(N)] A [int(input()) for n in range(N)] print(shellSort(N, A)) print shellSort(N, A) shellSort N A for i in range(N):print(A i range(N) range N if __name__ == '__main__':
    ALDS1_2D() __name__ == '__main__' __name__ '__main__' ALDS1_2D() ALDS1_2D def InsertionSort(A, n, g):
    c = 0
    for i in range(g, n):
        v, j = A[i], i - g
        while j>=0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            c += 1
        A[j+g] = v
    return c def InsertionSort(A, n, g):
    c = 0
    for i in range(g, n):
        v, j = A[i], i - g
        while j>=0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            c += 1
        A[j+g] = v
    return c InsertionSort def shellSort(n, A):
    cnt, G, gm = 0, [], 1
    while True:
        G = [gm] + G
        if gm*5+1 > n: break
        gm = 5*gm +1
    m = len(G)
    print(m)
    print(*G)
    for i in range(m):
        cnt += InsertionSort(A,n,G[i])
    return cnt def shellSort(n, A):
    cnt, G, gm = 0, [], 1
    while True:
        G = [gm] + G
        if gm*5+1 > n: break
        gm = 5*gm +1
    m = len(G)
    print(m)
    print(*G)
    for i in range(m):
        cnt += InsertionSort(A,n,G[i])
    return cnt shellSort def ALDS1_2D():
    N = int(input())
    A = [int(input()) for n in range(N)]
    print(shellSort(N, A))
    for i in range(N):print(A[i]) def ALDS1_2D():
    N = int(input())
    A = [int(input()) for n in range(N)]
    print(shellSort(N, A))
    for i in range(N):print(A[i]) ALDS1_2D
def InsertionSort(A, n, g):
    c = 0
    for i in range(g, n):
        v, j = A[i], i - g
        while j>=0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            c += 1
        A[j+g] = v
    return c
def shellSort(n, A):
    cnt, G, gm = 0, [], 1
    while True:
        G = [gm] + G
        if gm*5+1 > n: break
        gm = 5*gm +1
    m = len(G)
    print(m)
    print(*G)
    for i in range(m):
        cnt += InsertionSort(A,n,G[i])
    return cnt


def ALDS1_2D():
    N = int(input())
    A = [int(input()) for n in range(N)]
    print(shellSort(N, A))
    for i in range(N):print(A[i])

if __name__ == '__main__':
    ALDS1_2D()