def insertionSort(A, n, g):
    cnti = 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
            cnti += 1
        A[j+g] = v
    return cnti
def shellSort(A,n):
    cnt = 0
    G = [1]
    h = 1
    for k in range(int(n**0.33333333)+1):
        h = 3*h + 1
        if (h <= n and len(G) < 100):
            G.append(h)
        elif(len(G) == 100):
            break    
    G.reverse()
    m = len(G)
    for i in range(m):
        cnt += insertionSort(A, n, G[i])
    print(m)
    for i in range(m):
        if (i == m-1):
            print('{}'.format(G[i]), end = '')
        else:
            print('{}'.format(G[i]), end = ' ')
    return cnt
        
        
        
n = int(input())
nlist = []
for i in range(n):
    x = int(input())
    nlist.append(x)
    
c = shellSort(nlist,n)
print()
print(c)
for i in nlist:
    print(i) def insertionSort(A, n, g):
    cnti = 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
            cnti += 1
        A[j+g] = v
    return cnti insertionSort cnti = 0 cnti 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
            cnti += 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
            cnti += 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 cnti += 1 cnti 1 A[j+g] = v A[j+g] A j+g j g v return cnti cnti A A n n g g def shellSort(A,n):
    cnt = 0
    G = [1]
    h = 1
    for k in range(int(n**0.33333333)+1):
        h = 3*h + 1
        if (h <= n and len(G) < 100):
            G.append(h)
        elif(len(G) == 100):
            break    
    G.reverse()
    m = len(G)
    for i in range(m):
        cnt += insertionSort(A, n, G[i])
    print(m)
    for i in range(m):
        if (i == m-1):
            print('{}'.format(G[i]), end = '')
        else:
            print('{}'.format(G[i]), end = ' ')
    return cnt
        
        
         shellSort cnt = 0 cnt 0 G = [1] G [1] 1 h = 1 h 1 for k in range(int(n**0.33333333)+1):
        h = 3*h + 1
        if (h <= n and len(G) < 100):
            G.append(h)
        elif(len(G) == 100):
            break    
     k range(int(n**0.33333333)+1) range int(n**0.33333333)+1 int(n**0.33333333) int n**0.33333333 n 0.33333333 1 h = 3*h + 1 h 3*h + 1 3*h 3 h 1 if (h <= n and len(G) < 100):
            G.append(h)
        elif(len(G) == 100):
            break    
     h <= n and len(G) < 100 h <= n h n len(G) < 100 len(G) len G 100 G.append(h) G.append G append h elif(len(G) == 100):
            break    
     len(G) == 100 len(G) len G 100 break G.reverse() G.reverse G reverse m = len(G) m len(G) len G 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(m) print m for i in range(m):
        if (i == m-1):
            print('{}'.format(G[i]), end = '')
        else:
            print('{}'.format(G[i]), end = ' ')
     i range(m) range m if (i == m-1):
            print('{}'.format(G[i]), end = '')
        else:
            print('{}'.format(G[i]), end = ' ')
     i == m-1 i m-1 m 1 print('{}'.format(G[i]), end = '') print '{}'.format(G[i]) '{}'.format '{}' format G[i] G i end = '' end '' print('{}'.format(G[i]), end = ' ') print '{}'.format(G[i]) '{}'.format '{}' format G[i] G i end = ' ' end ' ' return cnt cnt A A n n n = int(input()) n int(input()) int input() input nlist = [] nlist [] for i in range(n):
    x = int(input())
    nlist.append(x)
     i range(n) range n x = int(input()) x int(input()) int input() input nlist.append(x) nlist.append nlist append x c = shellSort(nlist,n) c shellSort(nlist,n) shellSort nlist n print() print print(c) print c for i in nlist:
    print(i) i nlist print(i) print i def insertionSort(A, n, g):
    cnti = 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
            cnti += 1
        A[j+g] = v
    return cnti def insertionSort(A, n, g):
    cnti = 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
            cnti += 1
        A[j+g] = v
    return cnti insertionSort c = shellSort(nlist,n) shellSort(nlist,n) c nlist = [] [] nlist n = int(input()) int(input()) n def shellSort(A,n):
    cnt = 0
    G = [1]
    h = 1
    for k in range(int(n**0.33333333)+1):
        h = 3*h + 1
        if (h <= n and len(G) < 100):
            G.append(h)
        elif(len(G) == 100):
            break    
    G.reverse()
    m = len(G)
    for i in range(m):
        cnt += insertionSort(A, n, G[i])
    print(m)
    for i in range(m):
        if (i == m-1):
            print('{}'.format(G[i]), end = '')
        else:
            print('{}'.format(G[i]), end = ' ')
    return cnt
        
        
         def shellSort(A,n):
    cnt = 0
    G = [1]
    h = 1
    for k in range(int(n**0.33333333)+1):
        h = 3*h + 1
        if (h <= n and len(G) < 100):
            G.append(h)
        elif(len(G) == 100):
            break    
    G.reverse()
    m = len(G)
    for i in range(m):
        cnt += insertionSort(A, n, G[i])
    print(m)
    for i in range(m):
        if (i == m-1):
            print('{}'.format(G[i]), end = '')
        else:
            print('{}'.format(G[i]), end = ' ')
    return cnt
        
        
         shellSort x = int(input()) int(input()) x
def insertionSort(A, n, g):
    cnti = 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
            cnti += 1
        A[j+g] = v
    return cnti
def shellSort(A,n):
    cnt = 0
    G = [1]
    h = 1
    for k in range(int(n**0.33333333)+1):
        h = 3*h + 1
        if (h <= n and len(G) < 100):
            G.append(h)
        elif(len(G) == 100):
            break    
    G.reverse()
    m = len(G)
    for i in range(m):
        cnt += insertionSort(A, n, G[i])
    print(m)
    for i in range(m):
        if (i == m-1):
            print('{}'.format(G[i]), end = '')
        else:
            print('{}'.format(G[i]), end = ' ')
    return cnt
        
        
        
n = int(input())
nlist = []
for i in range(n):
    x = int(input())
    nlist.append(x)
    
c = shellSort(nlist,n)
print()
print(c)
for i in nlist:
    print(i)
