import sys
count = 0

def insertionSort(A, n, g):
    global count
    for i in range(n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            count += 1
        A[j+g] = v
    return A

def shellSort(A, n):
    for i in range(m):
        insertionSort(A, n, G[i])
    return A

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

G = [1]
m = 1
while True:
    x = 3 * G[m-1] + 1
    if x >= n: break
    G.append(x)
    m += 1
G = G[::-1]

shellSort(A, n)

print(m)
print(' '.join([str(i) for i in G]))
print(count)
for i in A:
    print(i) import sys sys count = 0 count 0 def insertionSort(A, n, g):
    global count
    for i in range(n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            count += 1
        A[j+g] = v
    return A insertionSort global count for i in range(n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            count += 1
        A[j+g] = v
     i range(n) range 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 += 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 += 1 count 1 A[j+g] = v A[j+g] A j+g j g v return A A A A n n g g def shellSort(A, n):
    for i in range(m):
        insertionSort(A, n, G[i])
    return A shellSort for i in range(m):
        insertionSort(A, n, G[i])
     i range(m) range m insertionSort(A, n, G[i]) insertionSort A n G[i] G i return A A 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 G = [1] G [1] 1 m = 1 m 1 while True:
    x = 3 * G[m-1] + 1
    if x >= n: break
    G.append(x)
    m += 1 True x = 3 * G[m-1] + 1 x 3 * G[m-1] + 1 3 * G[m-1] 3 G[m-1] G m-1 m 1 1 if x >= n: break
     x >= n x n G.append(x) G.append G append x m += 1 m 1 G = G[::-1] G G[::-1] G ::-1 -1 shellSort(A, n) shellSort A n print(m) print m str(i) for i in G for i in G i G for i in G str(i) str i print(' '.join([str(i) for i in G])) print ' '.join([str(i) for i in G]) ' '.join ' ' join [str(i) for i in G] print(count) print count for i in A:
    print(i) i A print(i) print i G = [1] [1] G n = int(input()) int(input()) n m += 1 1 m G = G[::-1] G[::-1] G A = [] [] A def shellSort(A, n):
    for i in range(m):
        insertionSort(A, n, G[i])
    return A def shellSort(A, n):
    for i in range(m):
        insertionSort(A, n, G[i])
    return A shellSort x = 3 * G[m-1] + 1 3 * G[m-1] + 1 x count = 0 0 count def insertionSort(A, n, g):
    global count
    for i in range(n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            count += 1
        A[j+g] = v
    return A def insertionSort(A, n, g):
    global count
    for i in range(n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            count += 1
        A[j+g] = v
    return A insertionSort m = 1 1 m
import sys
count = 0

def insertionSort(A, n, g):
    global count
    for i in range(n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            count += 1
        A[j+g] = v
    return A

def shellSort(A, n):
    for i in range(m):
        insertionSort(A, n, G[i])
    return A

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

G = [1]
m = 1
while True:
    x = 3 * G[m-1] + 1
    if x >= n: break
    G.append(x)
    m += 1
G = G[::-1]

shellSort(A, n)

print(m)
print(' '.join([str(i) for i in G]))
print(count)
for i in A:
    print(i)