import math
import sys

count = 0
m = 0
G = []

def insertion_sort(A, N, g):
    global count
    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 = j - g
            count += 1
        A[j + g] = v

# h_(i+1) = 3h_i + 1 が最良の間隔 (らしい)
def shell_sort(A, N):
    global m, G
    m = math.floor(math.log(2*N+1, 3))
    G = [int((pow(3, i)-1)/2) for i in range(m, 0, -1)]

    for i in range(m):
        insertion_sort(A, N, G[i])


n = int(input())
A = list(map(int, sys.stdin.readlines()))
shell_sort(A, n)

print(m)
print(' '.join([str(h) for h in G]))
print(count)
for x in A:
    print(x) import math math import sys sys count = 0 count 0 m = 0 m 0 G = [] G [] def insertion_sort(A, N, g):
    global count
    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 = j - g
            count += 1
        A[j + g] = v

# h_(i+1) = 3h_i + 1 が最良の間隔 (らしい) insertion_sort global count 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 = j - g
            count += 1
        A[j + g] = v

# h_(i+1) = 3h_i + 1 が最良の間隔 (らしい) 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 = 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 A A N N g g def shell_sort(A, N):
    global m, G
    m = math.floor(math.log(2*N+1, 3))
    G = [int((pow(3, i)-1)/2) for i in range(m, 0, -1)]

    for i in range(m):
        insertion_sort(A, N, G[i]) shell_sort global m, G m = math.floor(math.log(2*N+1, 3)) m math.floor(math.log(2*N+1, 3)) math.floor math floor math.log(2*N+1, 3) math.log math log 2*N+1 2*N 2 N 1 3 int((pow(3, i)-1)/2) for i in range(m, 0, -1) for i in range(m, 0, -1) i range(m, 0, -1) range m 0 -1 for i in range(m, 0, -1) int((pow(3, i)-1)/2) int (pow(3, i)-1)/2 pow(3, i)-1 pow(3, i) pow 3 i 1 2 G = [int((pow(3, i)-1)/2) for i in range(m, 0, -1)] G [int((pow(3, i)-1)/2) for i in range(m, 0, -1)] for i in range(m):
        insertion_sort(A, N, G[i]) i range(m) range m insertion_sort(A, N, G[i]) insertion_sort A N G[i] G i A A N N n = int(input()) n int(input()) int input() input A = list(map(int, sys.stdin.readlines())) A list(map(int, sys.stdin.readlines())) list map(int, sys.stdin.readlines()) map int sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines shell_sort(A, n) shell_sort A n print(m) print m str(h) for h in G for h in G h G for h in G str(h) str h print(' '.join([str(h) for h in G])) print ' '.join([str(h) for h in G]) ' '.join ' ' join [str(h) for h in G] print(count) print count for x in A:
    print(x) x A print(x) print x n = int(input()) int(input()) n G = [] [] G def shell_sort(A, N):
    global m, G
    m = math.floor(math.log(2*N+1, 3))
    G = [int((pow(3, i)-1)/2) for i in range(m, 0, -1)]

    for i in range(m):
        insertion_sort(A, N, G[i]) def shell_sort(A, N):
    global m, G
    m = math.floor(math.log(2*N+1, 3))
    G = [int((pow(3, i)-1)/2) for i in range(m, 0, -1)]

    for i in range(m):
        insertion_sort(A, N, G[i]) shell_sort count = 0 0 count A = list(map(int, sys.stdin.readlines())) list(map(int, sys.stdin.readlines())) A m = 0 0 m def insertion_sort(A, N, g):
    global count
    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 = j - g
            count += 1
        A[j + g] = v

# h_(i+1) = 3h_i + 1 が最良の間隔 (らしい) def insertion_sort(A, N, g):
    global count
    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 = j - g
            count += 1
        A[j + g] = v

# h_(i+1) = 3h_i + 1 が最良の間隔 (らしい) insertion_sort
import math
import sys

count = 0
m = 0
G = []

def insertion_sort(A, N, g):
    global count
    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 = j - g
            count += 1
        A[j + g] = v

# h_(i+1) = 3h_i + 1 が最良の間隔 (らしい)
def shell_sort(A, N):
    global m, G
    m = math.floor(math.log(2*N+1, 3))
    G = [int((pow(3, i)-1)/2) for i in range(m, 0, -1)]

    for i in range(m):
        insertion_sort(A, N, G[i])


n = int(input())
A = list(map(int, sys.stdin.readlines()))
shell_sort(A, n)

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