def insert_sort(A, n, g, cnt):
    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
            cnt += 1
        A[j+g] = v
    return cnt

def shellSort(A, n):
    cnt = 0
    G = []; h = 0
    while h <= n:
        if 3 * h + 1 <= n:
            h = 3 * h + 1
            G.append(h)
        else: break
    G = sorted(G, reverse=True)
    m = len(G)
    for i in range(m):
        cnt = insert_sort(A, n, G[i], cnt)
    return m, cnt, G

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

m, cnt, G = shellSort(A, n)
print(m)
for i in range(m):
    if i == m - 1:
        print(G[i])
    else:
        print(G[i], end=" ")
print(cnt)
for i in A:
    print(i)
 def insert_sort(A, n, g, cnt):
    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
            cnt += 1
        A[j+g] = v
    return cnt insert_sort 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
            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 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 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 cnt += 1 cnt 1 A[j+g] = v A[j+g] A j+g j g v return cnt cnt A A n n g g cnt cnt def shellSort(A, n):
    cnt = 0
    G = []; h = 0
    while h <= n:
        if 3 * h + 1 <= n:
            h = 3 * h + 1
            G.append(h)
        else: break
    G = sorted(G, reverse=True)
    m = len(G)
    for i in range(m):
        cnt = insert_sort(A, n, G[i], cnt)
    return m, cnt, G shellSort cnt = 0 cnt 0 G = [] G [] h = 0 h 0 while h <= n:
        if 3 * h + 1 <= n:
            h = 3 * h + 1
            G.append(h)
        else: break
     h <= n h n if 3 * h + 1 <= n:
            h = 3 * h + 1
            G.append(h)
        else: break
     3 * h + 1 <= n 3 * h + 1 3 * h 3 h 1 n h = 3 * h + 1 h 3 * h + 1 3 * h 3 h 1 G.append(h) G.append G append h G = sorted(G, reverse=True) G sorted(G, reverse=True) sorted G reverse=True reverse True m = len(G) m len(G) len G for i in range(m):
        cnt = insert_sort(A, n, G[i], cnt)
     i range(m) range m cnt = insert_sort(A, n, G[i], cnt) cnt insert_sort(A, n, G[i], cnt) insert_sort A n G[i] G i cnt return m, cnt, G return m, cnt, G m cnt G A A n n A = [] A [] n = int(input()) n int(input()) int input() input for i in range(n):
    A.append(int(input())) i range(n) range n A.append(int(input())) A.append A append int(input()) int input() input m, cnt, G = shellSort(A, n) m shellSort(A, n) shellSort A n cnt G print(m) print m for i in range(m):
    if i == m - 1:
        print(G[i])
    else:
        print(G[i], end=" ") i range(m) range m if i == m - 1:
        print(G[i])
    else:
        print(G[i], end=" ") i == m - 1 i m - 1 m 1 print(G[i]) print G[i] G i print(G[i], end=" ") print G[i] G i end=" " end " " print(cnt) print cnt for i in A:
    print(i) i A print(i) print i G = shellSort(A, n) shellSort(A, n) G n = int(input()) int(input()) n m, cnt, G = shellSort(A, n) shellSort(A, n) m A = [] [] A cnt, G = shellSort(A, n) shellSort(A, n) cnt def insert_sort(A, n, g, cnt):
    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
            cnt += 1
        A[j+g] = v
    return cnt def insert_sort(A, n, g, cnt):
    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
            cnt += 1
        A[j+g] = v
    return cnt insert_sort def shellSort(A, n):
    cnt = 0
    G = []; h = 0
    while h <= n:
        if 3 * h + 1 <= n:
            h = 3 * h + 1
            G.append(h)
        else: break
    G = sorted(G, reverse=True)
    m = len(G)
    for i in range(m):
        cnt = insert_sort(A, n, G[i], cnt)
    return m, cnt, G def shellSort(A, n):
    cnt = 0
    G = []; h = 0
    while h <= n:
        if 3 * h + 1 <= n:
            h = 3 * h + 1
            G.append(h)
        else: break
    G = sorted(G, reverse=True)
    m = len(G)
    for i in range(m):
        cnt = insert_sort(A, n, G[i], cnt)
    return m, cnt, G shellSort
def insert_sort(A, n, g, cnt):
    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
            cnt += 1
        A[j+g] = v
    return cnt

def shellSort(A, n):
    cnt = 0
    G = []; h = 0
    while h <= n:
        if 3 * h + 1 <= n:
            h = 3 * h + 1
            G.append(h)
        else: break
    G = sorted(G, reverse=True)
    m = len(G)
    for i in range(m):
        cnt = insert_sort(A, n, G[i], cnt)
    return m, cnt, G

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

m, cnt, G = shellSort(A, n)
print(m)
for i in range(m):
    if i == m - 1:
        print(G[i])
    else:
        print(G[i], end=" ")
print(cnt)
for i in A:
    print(i)

