n = int(input())
cn= 1
an= [1]
i = 1

while cn < n / 4: 
    an.append(cn*3+1)
    cn=cn*3+1
an.sort(reverse=True)

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 = j-g
            cnt+=1
        a[j + g]=v
    return cnt

def shellSort(a,n,an):
    cnt=0
    m = len(an)
    g = an
    for i in an:
        cnt += insertionSort(a,n,i)
    return cnt


x=[]
for i in range(n):
    x.append(int(input()))

print(len(an))
print(" ".join([str(i) for i in an]))
y= shellSort(x,n,an)
print(y)

for i in range(n):
    print(x[i]) n = int(input()) n int(input()) int input() input cn= 1 cn 1 an= [1] an [1] 1 i = 1 i 1 while cn < n / 4: 
    an.append(cn*3+1)
    cn=cn*3+1 cn < n / 4 cn n / 4 n 4 an.append(cn*3+1) an.append an append cn*3+1 cn*3 cn 3 1 cn=cn*3+1 cn cn*3+1 cn*3 cn 3 1 an.sort(reverse=True) an.sort an sort reverse=True reverse True 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 = j-g
            cnt+=1
        a[j + g]=v
    return cnt 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 = 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 = 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 return cnt cnt a a n n g g def shellSort(a,n,an):
    cnt=0
    m = len(an)
    g = an
    for i in an:
        cnt += insertionSort(a,n,i)
    return cnt shellSort cnt=0 cnt 0 m = len(an) m len(an) len an g = an g an for i in an:
        cnt += insertionSort(a,n,i)
     i an cnt += insertionSort(a,n,i) cnt insertionSort(a,n,i) insertionSort a n i return cnt cnt a a n n an an x=[] x [] for i in range(n):
    x.append(int(input())) i range(n) range n x.append(int(input())) x.append x append int(input()) int input() input print(len(an)) print len(an) len an str(i) for i in an for i in an i an for i in an str(i) str i print(" ".join([str(i) for i in an])) print " ".join([str(i) for i in an]) " ".join " " join [str(i) for i in an] y= shellSort(x,n,an) y shellSort(x,n,an) shellSort x n an print(y) print y for i in range(n):
    print(x[i]) i range(n) range n print(x[i]) print x[i] x i 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 = j-g
            cnt+=1
        a[j + g]=v
    return cnt 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 = j-g
            cnt+=1
        a[j + g]=v
    return cnt insertionSort cn= 1 1 cn def shellSort(a,n,an):
    cnt=0
    m = len(an)
    g = an
    for i in an:
        cnt += insertionSort(a,n,i)
    return cnt def shellSort(a,n,an):
    cnt=0
    m = len(an)
    g = an
    for i in an:
        cnt += insertionSort(a,n,i)
    return cnt shellSort n = int(input()) int(input()) n y= shellSort(x,n,an) shellSort(x,n,an) y i = 1 1 i x=[] [] x an= [1] [1] an cn=cn*3+1 cn*3+1 cn
n = int(input())
cn= 1
an= [1]
i = 1

while cn < n / 4: 
    an.append(cn*3+1)
    cn=cn*3+1
an.sort(reverse=True)

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 = j-g
            cnt+=1
        a[j + g]=v
    return cnt

def shellSort(a,n,an):
    cnt=0
    m = len(an)
    g = an
    for i in an:
        cnt += insertionSort(a,n,i)
    return cnt


x=[]
for i in range(n):
    x.append(int(input()))

print(len(an))
print(" ".join([str(i) for i in an]))
y= shellSort(x,n,an)
print(y)

for i in range(n):
    print(x[i])