#シェルソート
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        #その間隔で比較できる最も左から始める.vが基準値
        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

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

cnt = 0
G = [1]
for i in range(100):
    if n < 1 + 3*G[-1]:
        break
    G.append(1+3*G[-1])
m = len(G)
G.reverse()

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

print(m)
print(*G)
print(cnt)
print(*A, sep='\n') def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        #その間隔で比較できる最も左から始める.vが基準値
        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が基準値
        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 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)] cnt = 0 cnt 0 G = [1] G [1] 1 for i in range(100):
    if n < 1 + 3*G[-1]:
        break
    G.append(1+3*G[-1]) i range(100) range 100 if n < 1 + 3*G[-1]:
        break
     n < 1 + 3*G[-1] n 1 + 3*G[-1] 1 3*G[-1] 3 G[-1] G -1 break G.append(1+3*G[-1]) G.append G append 1+3*G[-1] 1 3*G[-1] 3 G[-1] G -1 m = len(G) m len(G) len G G.reverse() G.reverse G reverse 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 print(m) print m print(*G) print *G G print(cnt) print cnt print(*A, sep='\n') print *A A sep='\n' sep '\n' m = len(G) len(G) m G = [1] [1] G n = int(input()) int(input()) n cnt = 0 0 cnt def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        #その間隔で比較できる最も左から始める.vが基準値
        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が基準値
        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 A = [int(input()) for i in range(n)] [int(input()) for i in range(n)] A
#シェルソート
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        #その間隔で比較できる最も左から始める.vが基準値
        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

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

cnt = 0
G = [1]
for i in range(100):
    if n < 1 + 3*G[-1]:
        break
    G.append(1+3*G[-1])
m = len(G)
G.reverse()

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

print(m)
print(*G)
print(cnt)
print(*A, sep='\n')
