def insertion_sort(nums,n,g):
    global count
    
    for i in range(g,n):
        v=nums[i]
        j=i-g
        
        while (j>=0 and nums[j]>v):
            nums[j+g]=nums[j]
            j=j-g
            count+=1
        nums[j+g]=v


def shell_sort(nums,n):
    global count
    count=0
    m=-1
    test=0
    while test<=n:
        test=test*3+1
        m+=1
    G=[]
    h=0
    for i in range(m):
        h=h*3+1
        G.append(h)
    G.reverse()
    for i in range(m):
        insertion_sort(nums,n,G[i])
    return m,G,count,nums

def show(num):
    for i in range(len(num)):
        if i!=len(num):
            print(num[i],end=' ')
            
        else:
            print(num[i])

n=int(input())
nums=[int(input()) for j in range(n)]
answer_m,answer_G,answer_count,answer_nums=shell_sort(nums,n)
print(answer_m)
show(answer_G)
print()
print(answer_count)
for j in range(len(answer_nums)):
    print(answer_nums[j])
 def insertion_sort(nums,n,g):
    global count
    
    for i in range(g,n):
        v=nums[i]
        j=i-g
        
        while (j>=0 and nums[j]>v):
            nums[j+g]=nums[j]
            j=j-g
            count+=1
        nums[j+g]=v insertion_sort global count for i in range(g,n):
        v=nums[i]
        j=i-g
        
        while (j>=0 and nums[j]>v):
            nums[j+g]=nums[j]
            j=j-g
            count+=1
        nums[j+g]=v i range(g,n) range g n v=nums[i] v nums[i] nums i j=i-g j i-g i g while (j>=0 and nums[j]>v):
            nums[j+g]=nums[j]
            j=j-g
            count+=1
         j>=0 and nums[j]>v j>=0 j 0 nums[j]>v nums[j] nums j v nums[j+g]=nums[j] nums[j+g] nums j+g j g nums[j] nums j j=j-g j j-g j g count+=1 count 1 nums[j+g]=v nums[j+g] nums j+g j g v nums nums n n g g def shell_sort(nums,n):
    global count
    count=0
    m=-1
    test=0
    while test<=n:
        test=test*3+1
        m+=1
    G=[]
    h=0
    for i in range(m):
        h=h*3+1
        G.append(h)
    G.reverse()
    for i in range(m):
        insertion_sort(nums,n,G[i])
    return m,G,count,nums shell_sort global count count=0 count 0 m=-1 m -1 test=0 test 0 while test<=n:
        test=test*3+1
        m+=1
     test<=n test n test=test*3+1 test test*3+1 test*3 test 3 1 m+=1 m 1 G=[] G [] h=0 h 0 for i in range(m):
        h=h*3+1
        G.append(h)
     i range(m) range m h=h*3+1 h h*3+1 h*3 h 3 1 G.append(h) G.append G append h G.reverse() G.reverse G reverse for i in range(m):
        insertion_sort(nums,n,G[i])
     i range(m) range m insertion_sort(nums,n,G[i]) insertion_sort nums n G[i] G i return m,G,count,nums return m,G,count,nums m G count nums nums nums n n def show(num):
    for i in range(len(num)):
        if i!=len(num):
            print(num[i],end=' ')
            
        else:
            print(num[i]) show for i in range(len(num)):
        if i!=len(num):
            print(num[i],end=' ')
            
        else:
            print(num[i]) i range(len(num)) range len(num) len num if i!=len(num):
            print(num[i],end=' ')
            
        else:
            print(num[i]) i!=len(num) i len(num) len num print(num[i],end=' ') print num[i] num i end=' ' end ' ' print(num[i]) print num[i] num i num num n=int(input()) n int(input()) int input() input int(input()) for j in range(n) for j in range(n) j range(n) range n for j in range(n) int(input()) int input() input nums=[int(input()) for j in range(n)] nums [int(input()) for j in range(n)] answer_m,answer_G,answer_count,answer_nums=shell_sort(nums,n) answer_m shell_sort(nums,n) shell_sort nums n answer_G answer_count answer_nums print(answer_m) print answer_m show(answer_G) show answer_G print() print print(answer_count) print answer_count for j in range(len(answer_nums)):
    print(answer_nums[j]) j range(len(answer_nums)) range len(answer_nums) len answer_nums print(answer_nums[j]) print answer_nums[j] answer_nums j def shell_sort(nums,n):
    global count
    count=0
    m=-1
    test=0
    while test<=n:
        test=test*3+1
        m+=1
    G=[]
    h=0
    for i in range(m):
        h=h*3+1
        G.append(h)
    G.reverse()
    for i in range(m):
        insertion_sort(nums,n,G[i])
    return m,G,count,nums def shell_sort(nums,n):
    global count
    count=0
    m=-1
    test=0
    while test<=n:
        test=test*3+1
        m+=1
    G=[]
    h=0
    for i in range(m):
        h=h*3+1
        G.append(h)
    G.reverse()
    for i in range(m):
        insertion_sort(nums,n,G[i])
    return m,G,count,nums shell_sort answer_nums=shell_sort(nums,n) shell_sort(nums,n) answer_nums n=int(input()) int(input()) n nums=[int(input()) for j in range(n)] [int(input()) for j in range(n)] nums answer_G,answer_count,answer_nums=shell_sort(nums,n) shell_sort(nums,n) answer_G answer_count,answer_nums=shell_sort(nums,n) shell_sort(nums,n) answer_count def insertion_sort(nums,n,g):
    global count
    
    for i in range(g,n):
        v=nums[i]
        j=i-g
        
        while (j>=0 and nums[j]>v):
            nums[j+g]=nums[j]
            j=j-g
            count+=1
        nums[j+g]=v def insertion_sort(nums,n,g):
    global count
    
    for i in range(g,n):
        v=nums[i]
        j=i-g
        
        while (j>=0 and nums[j]>v):
            nums[j+g]=nums[j]
            j=j-g
            count+=1
        nums[j+g]=v insertion_sort answer_m,answer_G,answer_count,answer_nums=shell_sort(nums,n) shell_sort(nums,n) answer_m def show(num):
    for i in range(len(num)):
        if i!=len(num):
            print(num[i],end=' ')
            
        else:
            print(num[i]) def show(num):
    for i in range(len(num)):
        if i!=len(num):
            print(num[i],end=' ')
            
        else:
            print(num[i]) show
def insertion_sort(nums,n,g):
    global count
    
    for i in range(g,n):
        v=nums[i]
        j=i-g
        
        while (j>=0 and nums[j]>v):
            nums[j+g]=nums[j]
            j=j-g
            count+=1
        nums[j+g]=v


def shell_sort(nums,n):
    global count
    count=0
    m=-1
    test=0
    while test<=n:
        test=test*3+1
        m+=1
    G=[]
    h=0
    for i in range(m):
        h=h*3+1
        G.append(h)
    G.reverse()
    for i in range(m):
        insertion_sort(nums,n,G[i])
    return m,G,count,nums

def show(num):
    for i in range(len(num)):
        if i!=len(num):
            print(num[i],end=' ')
            
        else:
            print(num[i])

n=int(input())
nums=[int(input()) for j in range(n)]
answer_m,answer_G,answer_count,answer_nums=shell_sort(nums,n)
print(answer_m)
show(answer_G)
print()
print(answer_count)
for j in range(len(answer_nums)):
    print(answer_nums[j])

