#ALDS1_2-C Sort 1 - Shell Sort
def insertionSort(A,n,g):
    cnt=0
    i=g
    while(i<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
        i+=1
    return cnt


def shellSort(A,n):
    cnt=0
    G=[]
    h=1
    m=0
    shells=""
    while h<n:
        G.insert(0,h)
        shells = " "+str(h)+shells
        h=h*3+1
        m+=1

    if(shells==""):
        print("1")
        shells=" 1"
    else:
        print(m)
    print(shells[1:])
    for i in range(m):
        cnt+=insertionSort(A,n,G[i])
    print(cnt)

n=int(input())
A=[]
for i in range(n):
    A.append(int(input()))
shellSort(A,n)
for i in range(n):
    print(A[i]) def insertionSort(A,n,g):
    cnt=0
    i=g
    while(i<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
        i+=1
    return cnt insertionSort cnt=0 cnt 0 i=g i g while(i<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
        i+=1
     i<n i 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=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 i+=1 i 1 return cnt cnt A A n n g g def shellSort(A,n):
    cnt=0
    G=[]
    h=1
    m=0
    shells=""
    while h<n:
        G.insert(0,h)
        shells = " "+str(h)+shells
        h=h*3+1
        m+=1

    if(shells==""):
        print("1")
        shells=" 1"
    else:
        print(m)
    print(shells[1:])
    for i in range(m):
        cnt+=insertionSort(A,n,G[i])
    print(cnt) shellSort cnt=0 cnt 0 G=[] G [] h=1 h 1 m=0 m 0 shells="" shells "" while h<n:
        G.insert(0,h)
        shells = " "+str(h)+shells
        h=h*3+1
        m+=1

     h<n h n G.insert(0,h) G.insert G insert 0 h shells = " "+str(h)+shells shells " "+str(h)+shells " "+str(h) " " str(h) str h shells h=h*3+1 h h*3+1 h*3 h 3 1 m+=1 m 1 if(shells==""):
        print("1")
        shells=" 1"
    else:
        print(m)
     shells=="" shells "" print("1") print "1" shells=" 1" shells " 1" print(m) print m print(shells[1:]) print shells[1:] shells 1: 1 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 print(cnt) print cnt A A n n n=int(input()) n int(input()) int input() input A=[] A [] for i in range(n):
    A.append(int(input())) i range(n) range n A.append(int(input())) A.append A append int(input()) int input() input shellSort(A,n) shellSort A n for i in range(n):
    print(A[i]) i range(n) range n print(A[i]) print A[i] A i A=[] [] A n=int(input()) int(input()) n def shellSort(A,n):
    cnt=0
    G=[]
    h=1
    m=0
    shells=""
    while h<n:
        G.insert(0,h)
        shells = " "+str(h)+shells
        h=h*3+1
        m+=1

    if(shells==""):
        print("1")
        shells=" 1"
    else:
        print(m)
    print(shells[1:])
    for i in range(m):
        cnt+=insertionSort(A,n,G[i])
    print(cnt) def shellSort(A,n):
    cnt=0
    G=[]
    h=1
    m=0
    shells=""
    while h<n:
        G.insert(0,h)
        shells = " "+str(h)+shells
        h=h*3+1
        m+=1

    if(shells==""):
        print("1")
        shells=" 1"
    else:
        print(m)
    print(shells[1:])
    for i in range(m):
        cnt+=insertionSort(A,n,G[i])
    print(cnt) shellSort def insertionSort(A,n,g):
    cnt=0
    i=g
    while(i<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
        i+=1
    return cnt def insertionSort(A,n,g):
    cnt=0
    i=g
    while(i<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
        i+=1
    return cnt insertionSort
#ALDS1_2-C Sort 1 - Shell Sort
def insertionSort(A,n,g):
    cnt=0
    i=g
    while(i<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
        i+=1
    return cnt


def shellSort(A,n):
    cnt=0
    G=[]
    h=1
    m=0
    shells=""
    while h<n:
        G.insert(0,h)
        shells = " "+str(h)+shells
        h=h*3+1
        m+=1

    if(shells==""):
        print("1")
        shells=" 1"
    else:
        print(m)
    print(shells[1:])
    for i in range(m):
        cnt+=insertionSort(A,n,G[i])
    print(cnt)

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