def insertion_sort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0)&(A[j]>v):
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return A, cnt
    
    
def shell_sort(A,n):
    G = []
    g = 1
    while True:
        G.append(g)
        g = 3*g+1
        if g>n:
            break
    m = len(G)
    G = G[::-1]
    cnt = 0
    for i in range(m):
        A,cnt_tmp = insertion_sort(A,n,G[i])
        cnt += cnt_tmp
    return G,A,cnt
    

n = int(input())
A = [int(input()) for i in range(n)]

G,A,cnt = shell_sort(A,n)
print(len(G))
print(*G)
print(cnt)
for i in range(n):
    print(A[i]) def insertion_sort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0)&(A[j]>v):
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return A, cnt
    
     insertion_sort cnt = 0 cnt 0 for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0)&(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)&(A[j]>v):
            A[j+g] = A[j]
            j = j - g
            cnt += 1
         (j>=0)&(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 A, cnt return A, cnt A cnt A A n n g g def shell_sort(A,n):
    G = []
    g = 1
    while True:
        G.append(g)
        g = 3*g+1
        if g>n:
            break
    m = len(G)
    G = G[::-1]
    cnt = 0
    for i in range(m):
        A,cnt_tmp = insertion_sort(A,n,G[i])
        cnt += cnt_tmp
    return G,A,cnt
     shell_sort G = [] G [] g = 1 g 1 while True:
        G.append(g)
        g = 3*g+1
        if g>n:
            break
     True G.append(g) G.append G append g g = 3*g+1 g 3*g+1 3*g 3 g 1 if g>n:
            break
     g>n g n break m = len(G) m len(G) len G G = G[::-1] G G[::-1] G ::-1 -1 cnt = 0 cnt 0 for i in range(m):
        A,cnt_tmp = insertion_sort(A,n,G[i])
        cnt += cnt_tmp
     i range(m) range m A,cnt_tmp = insertion_sort(A,n,G[i]) A insertion_sort(A,n,G[i]) insertion_sort A n G[i] G i cnt_tmp cnt += cnt_tmp cnt cnt_tmp return G,A,cnt return G,A,cnt G A cnt A A n n 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 A = [int(input()) for i in range(n)] A [int(input()) for i in range(n)] G,A,cnt = shell_sort(A,n) G shell_sort(A,n) shell_sort A n A cnt print(len(G)) print len(G) len G print(*G) print *G G print(cnt) print cnt for i in range(n):
    print(A[i]) i range(n) range n print(A[i]) print A[i] A i A = [int(input()) for i in range(n)] [int(input()) for i in range(n)] A A,cnt = shell_sort(A,n) shell_sort(A,n) A G,A,cnt = shell_sort(A,n) shell_sort(A,n) G def insertion_sort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0)&(A[j]>v):
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return A, cnt
    
     def insertion_sort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0)&(A[j]>v):
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return A, cnt
    
     insertion_sort n = int(input()) int(input()) n def shell_sort(A,n):
    G = []
    g = 1
    while True:
        G.append(g)
        g = 3*g+1
        if g>n:
            break
    m = len(G)
    G = G[::-1]
    cnt = 0
    for i in range(m):
        A,cnt_tmp = insertion_sort(A,n,G[i])
        cnt += cnt_tmp
    return G,A,cnt
     def shell_sort(A,n):
    G = []
    g = 1
    while True:
        G.append(g)
        g = 3*g+1
        if g>n:
            break
    m = len(G)
    G = G[::-1]
    cnt = 0
    for i in range(m):
        A,cnt_tmp = insertion_sort(A,n,G[i])
        cnt += cnt_tmp
    return G,A,cnt
     shell_sort cnt = shell_sort(A,n) shell_sort(A,n) cnt
def insertion_sort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0)&(A[j]>v):
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return A, cnt
    
    
def shell_sort(A,n):
    G = []
    g = 1
    while True:
        G.append(g)
        g = 3*g+1
        if g>n:
            break
    m = len(G)
    G = G[::-1]
    cnt = 0
    for i in range(m):
        A,cnt_tmp = insertion_sort(A,n,G[i])
        cnt += cnt_tmp
    return G,A,cnt
    

n = int(input())
A = [int(input()) for i in range(n)]

G,A,cnt = shell_sort(A,n)
print(len(G))
print(*G)
print(cnt)
for i in range(n):
    print(A[i])
