def i_sort(A,n,g):
    global count
    
    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
            count = count + 1
        A[j + g] = v
        
def shellsort(A,n):
    global m
    global G
    
    h = 1
    while(True):
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1
    
    m = len(G)
    G.reverse()
    
    for i in range(m):
        i_sort(A,n,G[i])
        
if __name__ == '__main__':
    N = int(input())
    R = [int(input()) for i in range(N)]
    
    count = 0
    G = []
    m = 0
    
    shellsort(R,N)
    
    print(m)
    print(" ".join(map(str,G)))
    print(count)
    for i in range(N):
        print(R[i]) def i_sort(A,n,g):
    global count
    
    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
            count = count + 1
        A[j + g] = v
         i_sort global count 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
            count = 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 = j - g
            count = 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 = j - g j j - g j g count = count + 1 count count + 1 count 1 A[j + g] = v A[j + g] A j + g j g v A A n n g g def shellsort(A,n):
    global m
    global G
    
    h = 1
    while(True):
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1
    
    m = len(G)
    G.reverse()
    
    for i in range(m):
        i_sort(A,n,G[i])
         shellsort global m global G h = 1 h 1 while(True):
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1
    
     True if h > n:
            break
         h > n h n break G.append(h) G.append G append h h = 3 * h + 1 h 3 * h + 1 3 * h 3 h 1 m = len(G) m len(G) len G G.reverse() G.reverse G reverse for i in range(m):
        i_sort(A,n,G[i])
         i range(m) range m i_sort(A,n,G[i]) i_sort A n G[i] G i A A n n if __name__ == '__main__':
    N = int(input())
    R = [int(input()) for i in range(N)]
    
    count = 0
    G = []
    m = 0
    
    shellsort(R,N)
    
    print(m)
    print(" ".join(map(str,G)))
    print(count)
    for i in range(N):
        print(R[i]) __name__ == '__main__' __name__ '__main__' N = int(input()) N int(input()) int input() input int(input()) for i in range(N) for i in range(N) i range(N) range N for i in range(N) int(input()) int input() input R = [int(input()) for i in range(N)] R [int(input()) for i in range(N)] count = 0 count 0 G = [] G [] m = 0 m 0 shellsort(R,N) shellsort R N print(m) print m print(" ".join(map(str,G))) print " ".join(map(str,G)) " ".join " " join map(str,G) map str G print(count) print count for i in range(N):
        print(R[i]) i range(N) range N print(R[i]) print R[i] R i count = 0 0 count N = int(input()) int(input()) N m = 0 0 m R = [int(input()) for i in range(N)] [int(input()) for i in range(N)] R def i_sort(A,n,g):
    global count
    
    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
            count = count + 1
        A[j + g] = v
         def i_sort(A,n,g):
    global count
    
    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
            count = count + 1
        A[j + g] = v
         i_sort def shellsort(A,n):
    global m
    global G
    
    h = 1
    while(True):
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1
    
    m = len(G)
    G.reverse()
    
    for i in range(m):
        i_sort(A,n,G[i])
         def shellsort(A,n):
    global m
    global G
    
    h = 1
    while(True):
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1
    
    m = len(G)
    G.reverse()
    
    for i in range(m):
        i_sort(A,n,G[i])
         shellsort G = [] [] G
def i_sort(A,n,g):
    global count
    
    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
            count = count + 1
        A[j + g] = v
        
def shellsort(A,n):
    global m
    global G
    
    h = 1
    while(True):
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1
    
    m = len(G)
    G.reverse()
    
    for i in range(m):
        i_sort(A,n,G[i])
        
if __name__ == '__main__':
    N = int(input())
    R = [int(input()) for i in range(N)]
    
    count = 0
    G = []
    m = 0
    
    shellsort(R,N)
    
    print(m)
    print(" ".join(map(str,G)))
    print(count)
    for i in range(N):
        print(R[i])
