def insertionSort(A, n, g):
    global 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
def shellSort(A, n):
    global cnt
    cnt = 0
    G = [1]
    while G[0] < n // 3:
        G[0:0] = [G[0] * 3 + 1]
    m = len(G)
    print(m)
    print(' '.join([str(g) for g in G]))
    for g in G:
        insertionSort(A, n, g)
    print(cnt)

n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
shellSort(A, n)
for a in A:
    print(a)
 def insertionSort(A, n, g):
    global 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 insertionSort global 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 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 A A n n g g def shellSort(A, n):
    global cnt
    cnt = 0
    G = [1]
    while G[0] < n // 3:
        G[0:0] = [G[0] * 3 + 1]
    m = len(G)
    print(m)
    print(' '.join([str(g) for g in G]))
    for g in G:
        insertionSort(A, n, g)
    print(cnt) shellSort global cnt cnt = 0 cnt 0 G = [1] G [1] 1 while G[0] < n // 3:
        G[0:0] = [G[0] * 3 + 1]
     G[0] < n // 3 G[0] G 0 n // 3 n 3 G[0:0] = [G[0] * 3 + 1] G[0:0] G 0:0 0 0 [G[0] * 3 + 1] G[0] * 3 + 1 G[0] * 3 G[0] G 0 3 1 m = len(G) m len(G) len G print(m) print m 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] for g in G:
        insertionSort(A, n, g)
     g G insertionSort(A, n, g) insertionSort A n g print(cnt) print cnt A A n n n = int(input()) n int(input()) int input() input A = [] A [] 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 shellSort(A, n) shellSort A n for a in A:
    print(a) a A print(a) print a n = int(input()) int(input()) n def insertionSort(A, n, g):
    global 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 def insertionSort(A, n, g):
    global 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 insertionSort def shellSort(A, n):
    global cnt
    cnt = 0
    G = [1]
    while G[0] < n // 3:
        G[0:0] = [G[0] * 3 + 1]
    m = len(G)
    print(m)
    print(' '.join([str(g) for g in G]))
    for g in G:
        insertionSort(A, n, g)
    print(cnt) def shellSort(A, n):
    global cnt
    cnt = 0
    G = [1]
    while G[0] < n // 3:
        G[0:0] = [G[0] * 3 + 1]
    m = len(G)
    print(m)
    print(' '.join([str(g) for g in G]))
    for g in G:
        insertionSort(A, n, g)
    print(cnt) shellSort A = [] [] A
def insertionSort(A, n, g):
    global 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
def shellSort(A, n):
    global cnt
    cnt = 0
    G = [1]
    while G[0] < n // 3:
        G[0:0] = [G[0] * 3 + 1]
    m = len(G)
    print(m)
    print(' '.join([str(g) for g in G]))
    for g in G:
        insertionSort(A, n, g)
    print(cnt)

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

