def insersionSort(A, N, count=0, g=1):
    # 間隔 g で挿入ソートを行う
    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
            count += 1
        A[j+g] = v
        
    return A, count

def shellSort():
    N, *A = map(int, open(0).read().split())
  
    G = [1]
    cursor = 2
    while True:
        g = (3 ** cursor - 1) // 2
        if g < N:
            G.append(g)
            cursor += 1
        else:
            break
    G = G[::-1]
    
    print(len(G))
    print(' '.join([str(g) for g in G]))
    
    count = 0
    for g in G:
        A, count = insersionSort(A, N, count, g)
    print(count)
    
    for a in A:
        print(a)
        
if __name__=="__main__":
    shellSort() def insersionSort(A, N, count=0, g=1):
    # 間隔 g で挿入ソートを行う
    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
            count += 1
        A[j+g] = v
        
    return A, count insersionSort 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
            count += 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
            count += 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 count += 1 count 1 A[j+g] = v A[j+g] A j+g j g v return A, count return A, count A count A A N N count=0 count 0 g=1 g 1 def shellSort():
    N, *A = map(int, open(0).read().split())
  
    G = [1]
    cursor = 2
    while True:
        g = (3 ** cursor - 1) // 2
        if g < N:
            G.append(g)
            cursor += 1
        else:
            break
    G = G[::-1]
    
    print(len(G))
    print(' '.join([str(g) for g in G]))
    
    count = 0
    for g in G:
        A, count = insersionSort(A, N, count, g)
    print(count)
    
    for a in A:
        print(a)
         shellSort N, *A = map(int, open(0).read().split()) N map(int, open(0).read().split()) map int open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split *A A G = [1] G [1] 1 cursor = 2 cursor 2 while True:
        g = (3 ** cursor - 1) // 2
        if g < N:
            G.append(g)
            cursor += 1
        else:
            break
     True g = (3 ** cursor - 1) // 2 g (3 ** cursor - 1) // 2 3 ** cursor - 1 3 ** cursor 3 cursor 1 2 if g < N:
            G.append(g)
            cursor += 1
        else:
            break
     g < N g N G.append(g) G.append G append g cursor += 1 cursor 1 break G = G[::-1] G G[::-1] G ::-1 -1 print(len(G)) print len(G) len G str(g) for g in G for g in G g G for g in G str(g) str g print(' '.join([str(g) for g in G])) print ' '.join([str(g) for g in G]) ' '.join ' ' join [str(g) for g in G] count = 0 count 0 for g in G:
        A, count = insersionSort(A, N, count, g)
     g G A, count = insersionSort(A, N, count, g) A insersionSort(A, N, count, g) insersionSort A N count g count print(count) print count for a in A:
        print(a)
         a A print(a) print a if __name__=="__main__":
    shellSort() __name__=="__main__" __name__ "__main__" shellSort() shellSort def shellSort():
    N, *A = map(int, open(0).read().split())
  
    G = [1]
    cursor = 2
    while True:
        g = (3 ** cursor - 1) // 2
        if g < N:
            G.append(g)
            cursor += 1
        else:
            break
    G = G[::-1]
    
    print(len(G))
    print(' '.join([str(g) for g in G]))
    
    count = 0
    for g in G:
        A, count = insersionSort(A, N, count, g)
    print(count)
    
    for a in A:
        print(a)
         def shellSort():
    N, *A = map(int, open(0).read().split())
  
    G = [1]
    cursor = 2
    while True:
        g = (3 ** cursor - 1) // 2
        if g < N:
            G.append(g)
            cursor += 1
        else:
            break
    G = G[::-1]
    
    print(len(G))
    print(' '.join([str(g) for g in G]))
    
    count = 0
    for g in G:
        A, count = insersionSort(A, N, count, g)
    print(count)
    
    for a in A:
        print(a)
         shellSort def insersionSort(A, N, count=0, g=1):
    # 間隔 g で挿入ソートを行う
    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
            count += 1
        A[j+g] = v
        
    return A, count def insersionSort(A, N, count=0, g=1):
    # 間隔 g で挿入ソートを行う
    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
            count += 1
        A[j+g] = v
        
    return A, count insersionSort
def insersionSort(A, N, count=0, g=1):
    # 間隔 g で挿入ソートを行う
    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
            count += 1
        A[j+g] = v
        
    return A, count

def shellSort():
    N, *A = map(int, open(0).read().split())
  
    G = [1]
    cursor = 2
    while True:
        g = (3 ** cursor - 1) // 2
        if g < N:
            G.append(g)
            cursor += 1
        else:
            break
    G = G[::-1]
    
    print(len(G))
    print(' '.join([str(g) for g in G]))
    
    count = 0
    for g in G:
        A, count = insersionSort(A, N, count, g)
    print(count)
    
    for a in A:
        print(a)
        
if __name__=="__main__":
    shellSort()
