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]
            j-=g
            cnt+=1
        A[j+g]=v
    return A,cnt
        # print(end='\n')
def shellSort(A,N):
    m=len(A)
    G=[1]
    fig=1
    a=0
    b=2
    while(True):
        fig=b**2*b
        # fig=fig*3+1
        if fig>m:break#超えたら
        G.append(fig)
        b+=1
    G=G[::-1]
    for i in G:
        sort,cnt=InsertionSort(A,N,i)
        a+=cnt
    print(len(G))
    for j in G:print(j,end=' ')
    print(end='\n')
    print(a)
    for k in sort:print(k,end='\n')



N=int(input())
A=[int(input()) for x in range(N)]
shellSort(A,N) 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]
            j-=g
            cnt+=1
        A[j+g]=v
    return A,cnt
        # print(end='\n') 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]
            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 A,cnt return A,cnt A cnt A A N N g g def shellSort(A,N):
    m=len(A)
    G=[1]
    fig=1
    a=0
    b=2
    while(True):
        fig=b**2*b
        # fig=fig*3+1
        if fig>m:break#超えたら
        G.append(fig)
        b+=1
    G=G[::-1]
    for i in G:
        sort,cnt=InsertionSort(A,N,i)
        a+=cnt
    print(len(G))
    for j in G:print(j,end=' ')
    print(end='\n')
    print(a)
    for k in sort:print(k,end='\n') shellSort m=len(A) m len(A) len A G=[1] G [1] 1 fig=1 fig 1 a=0 a 0 b=2 b 2 while(True):
        fig=b**2*b
        # fig=fig*3+1
        if fig>m:break#超えたら
        G.append(fig)
        b+=1
     True fig=b**2*b fig b**2*b b**2 b 2 b if fig>m:break#超えたら
         fig>m fig m G.append(fig) G.append G append fig b+=1 b 1 G=G[::-1] G G[::-1] G ::-1 -1 for i in G:
        sort,cnt=InsertionSort(A,N,i)
        a+=cnt
     i G sort,cnt=InsertionSort(A,N,i) sort InsertionSort(A,N,i) InsertionSort A N i cnt a+=cnt a cnt print(len(G)) print len(G) len G for j in G:print(j,end=' ')
     j G print(end='\n') print end='\n' end '\n' print(a) print a for k in sort:print(k,end=' k sort A A N N N=int(input()) N int(input()) int input() input int(input()) for x in range(N) for x in range(N) x range(N) range N for x in range(N) int(input()) int input() input A=[int(input()) for x in range(N)] A [int(input()) for x in range(N)] shellSort(A,N) shellSort A N N=int(input()) int(input()) N def shellSort(A,N):
    m=len(A)
    G=[1]
    fig=1
    a=0
    b=2
    while(True):
        fig=b**2*b
        # fig=fig*3+1
        if fig>m:break#超えたら
        G.append(fig)
        b+=1
    G=G[::-1]
    for i in G:
        sort,cnt=InsertionSort(A,N,i)
        a+=cnt
    print(len(G))
    for j in G:print(j,end=' ')
    print(end='\n')
    print(a)
    for k in sort:print(k,end='\n') def shellSort(A,N):
    m=len(A)
    G=[1]
    fig=1
    a=0
    b=2
    while(True):
        fig=b**2*b
        # fig=fig*3+1
        if fig>m:break#超えたら
        G.append(fig)
        b+=1
    G=G[::-1]
    for i in G:
        sort,cnt=InsertionSort(A,N,i)
        a+=cnt
    print(len(G))
    for j in G:print(j,end=' ')
    print(end='\n')
    print(a)
    for k in sort:print(k,end='\n') shellSort A=[int(input()) for x in range(N)] [int(input()) for x in range(N)] 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]
            j-=g
            cnt+=1
        A[j+g]=v
    return A,cnt
        # print(end='\n') 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]
            j-=g
            cnt+=1
        A[j+g]=v
    return A,cnt
        # print(end='\n') InsertionSort
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]
            j-=g
            cnt+=1
        A[j+g]=v
    return A,cnt
        # print(end='\n')
def shellSort(A,N):
    m=len(A)
    G=[1]
    fig=1
    a=0
    b=2
    while(True):
        fig=b**2*b
        # fig=fig*3+1
        if fig>m:break#超えたら
        G.append(fig)
        b+=1
    G=G[::-1]
    for i in G:
        sort,cnt=InsertionSort(A,N,i)
        a+=cnt
    print(len(G))
    for j in G:print(j,end=' ')
    print(end='\n')
    print(a)
    for k in sort:print(k,end='\n')



N=int(input())
A=[int(input()) for x in range(N)]
shellSort(A,N)
