import copy


def insertion_sort(arr, n, g, cnt):
    for i in range(g, n):
        v = arr[i]
        k = i - g
        while k >= 0 and arr[k] > v:
            arr[k + g] = arr[k]
            k = k - g
            cnt += 1
        arr[k + g] = v
    return arr, cnt


def shell_sort(arr, n, G):
    A = copy.deepcopy(arr)
    c = 0
    for i in G:
        A, c = insertion_sort(A, n, i, c)
    return A, c


n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
G = [1]
h = 1
while h * 3 + 1 <= n:
    h = 3 * h + 1
    G.append(h)

a, cnt = shell_sort(A, n, G[::-1])

print(len(G))
print(*G[::-1])
print(cnt)
for i in a:
    print(i)
 import copy copy def insertion_sort(arr, n, g, cnt):
    for i in range(g, n):
        v = arr[i]
        k = i - g
        while k >= 0 and arr[k] > v:
            arr[k + g] = arr[k]
            k = k - g
            cnt += 1
        arr[k + g] = v
    return arr, cnt insertion_sort for i in range(g, n):
        v = arr[i]
        k = i - g
        while k >= 0 and arr[k] > v:
            arr[k + g] = arr[k]
            k = k - g
            cnt += 1
        arr[k + g] = v
     i range(g, n) range g n v = arr[i] v arr[i] arr i k = i - g k i - g i g while k >= 0 and arr[k] > v:
            arr[k + g] = arr[k]
            k = k - g
            cnt += 1
         k >= 0 and arr[k] > v k >= 0 k 0 arr[k] > v arr[k] arr k v arr[k + g] = arr[k] arr[k + g] arr k + g k g arr[k] arr k k = k - g k k - g k g cnt += 1 cnt 1 arr[k + g] = v arr[k + g] arr k + g k g v return arr, cnt return arr, cnt arr cnt arr arr n n g g cnt cnt def shell_sort(arr, n, G):
    A = copy.deepcopy(arr)
    c = 0
    for i in G:
        A, c = insertion_sort(A, n, i, c)
    return A, c shell_sort A = copy.deepcopy(arr) A copy.deepcopy(arr) copy.deepcopy copy deepcopy arr c = 0 c 0 for i in G:
        A, c = insertion_sort(A, n, i, c)
     i G A, c = insertion_sort(A, n, i, c) A insertion_sort(A, n, i, c) insertion_sort A n i c c return A, c return A, c A c arr arr n n G G 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 h = 1 h 1 while h * 3 + 1 <= n:
    h = 3 * h + 1
    G.append(h) h * 3 + 1 <= n h * 3 + 1 h * 3 h 3 1 n h = 3 * h + 1 h 3 * h + 1 3 * h 3 h 1 G.append(h) G.append G append h a, cnt = shell_sort(A, n, G[::-1]) a shell_sort(A, n, G[::-1]) shell_sort A n G[::-1] G ::-1 -1 cnt print(len(G)) print len(G) len G print(*G[::-1]) print *G[::-1] G[::-1] G ::-1 -1 print(cnt) print cnt for i in a:
    print(i) i a print(i) print i a, cnt = shell_sort(A, n, G[::-1]) shell_sort(A, n, G[::-1]) a h = 3 * h + 1 3 * h + 1 h def shell_sort(arr, n, G):
    A = copy.deepcopy(arr)
    c = 0
    for i in G:
        A, c = insertion_sort(A, n, i, c)
    return A, c def shell_sort(arr, n, G):
    A = copy.deepcopy(arr)
    c = 0
    for i in G:
        A, c = insertion_sort(A, n, i, c)
    return A, c shell_sort h = 1 1 h def insertion_sort(arr, n, g, cnt):
    for i in range(g, n):
        v = arr[i]
        k = i - g
        while k >= 0 and arr[k] > v:
            arr[k + g] = arr[k]
            k = k - g
            cnt += 1
        arr[k + g] = v
    return arr, cnt def insertion_sort(arr, n, g, cnt):
    for i in range(g, n):
        v = arr[i]
        k = i - g
        while k >= 0 and arr[k] > v:
            arr[k + g] = arr[k]
            k = k - g
            cnt += 1
        arr[k + g] = v
    return arr, cnt insertion_sort n = int(input()) int(input()) n A = [] [] A G = [1] [1] G cnt = shell_sort(A, n, G[::-1]) shell_sort(A, n, G[::-1]) cnt
import copy


def insertion_sort(arr, n, g, cnt):
    for i in range(g, n):
        v = arr[i]
        k = i - g
        while k >= 0 and arr[k] > v:
            arr[k + g] = arr[k]
            k = k - g
            cnt += 1
        arr[k + g] = v
    return arr, cnt


def shell_sort(arr, n, G):
    A = copy.deepcopy(arr)
    c = 0
    for i in G:
        A, c = insertion_sort(A, n, i, c)
    return A, c


n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
G = [1]
h = 1
while h * 3 + 1 <= n:
    h = 3 * h + 1
    G.append(h)

a, cnt = shell_sort(A, n, G[::-1])

print(len(G))
print(*G[::-1])
print(cnt)
for i in a:
    print(i)

