from typing import Any,Sequence



def Insertion_sort(A:Sequence, N:int, g:int) -> None:
    global cnt
    for i in range(g, N):
        tmp = A[i]
        j = i - g
        while j >= 0 and A[j] > tmp:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = tmp


def shell_sort(A:Sequence, N:int) -> None:
    global cnt
    cnt = 0
    g = []
    h = 1
    while h <= N:
        g.append(h)
        h = (3 * h) + 1
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str, g)))

    for i in range(m):
        Insertion_sort(A, N, g[i])


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

shell_sort(B, n)
print(cnt)
[print(B[i]) for i in range(n)] from typing import Any,Sequence def Insertion_sort(A:Sequence, N:int, g:int) -> None:
    global cnt
    for i in range(g, N):
        tmp = A[i]
        j = i - g
        while j >= 0 and A[j] > tmp:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = tmp Insertion_sort global cnt for i in range(g, N):
        tmp = A[i]
        j = i - g
        while j >= 0 and A[j] > tmp:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = tmp i range(g, N) range g N tmp = A[i] tmp A[i] A i j = i - g j i - g i g while j >= 0 and A[j] > tmp:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
         j >= 0 and A[j] > tmp j >= 0 j 0 A[j] > tmp A[j] A j tmp 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 cnt += 1 cnt 1 A[j + g] = tmp A[j + g] A j + g j g tmp A:Sequence A N:int N g:int g def shell_sort(A:Sequence, N:int) -> None:
    global cnt
    cnt = 0
    g = []
    h = 1
    while h <= N:
        g.append(h)
        h = (3 * h) + 1
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str, g)))

    for i in range(m):
        Insertion_sort(A, N, g[i]) shell_sort global cnt cnt = 0 cnt 0 g = [] g [] h = 1 h 1 while h <= N:
        g.append(h)
        h = (3 * h) + 1
     h <= N h N g.append(h) g.append g append h h = (3 * h) + 1 h (3 * h) + 1 3 * h 3 h 1 g.reverse() g.reverse g reverse m = len(g) m len(g) len g print(m) print m print(' '.join(map(str, g))) print ' '.join(map(str, g)) ' '.join ' ' join map(str, g) map str g 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:Sequence A N:int N 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 B = [int(input()) for i in range(n)] B [int(input()) for i in range(n)] shell_sort(B, n) shell_sort B n print(cnt) print cnt print(B[i]) for i in range(n) for i in range(n) i range(n) range n for i in range(n) print(B[i]) print B[i] B i [print(B[i]) for i in range(n)] def shell_sort(A:Sequence, N:int) -> None:
    global cnt
    cnt = 0
    g = []
    h = 1
    while h <= N:
        g.append(h)
        h = (3 * h) + 1
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str, g)))

    for i in range(m):
        Insertion_sort(A, N, g[i]) def shell_sort(A:Sequence, N:int) -> None:
    global cnt
    cnt = 0
    g = []
    h = 1
    while h <= N:
        g.append(h)
        h = (3 * h) + 1
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str, g)))

    for i in range(m):
        Insertion_sort(A, N, g[i]) shell_sort def Insertion_sort(A:Sequence, N:int, g:int) -> None:
    global cnt
    for i in range(g, N):
        tmp = A[i]
        j = i - g
        while j >= 0 and A[j] > tmp:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = tmp def Insertion_sort(A:Sequence, N:int, g:int) -> None:
    global cnt
    for i in range(g, N):
        tmp = A[i]
        j = i - g
        while j >= 0 and A[j] > tmp:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = tmp Insertion_sort n = int(input()) int(input()) n B = [int(input()) for i in range(n)] [int(input()) for i in range(n)] B
from typing import Any,Sequence



def Insertion_sort(A:Sequence, N:int, g:int) -> None:
    global cnt
    for i in range(g, N):
        tmp = A[i]
        j = i - g
        while j >= 0 and A[j] > tmp:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = tmp


def shell_sort(A:Sequence, N:int) -> None:
    global cnt
    cnt = 0
    g = []
    h = 1
    while h <= N:
        g.append(h)
        h = (3 * h) + 1
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str, g)))

    for i in range(m):
        Insertion_sort(A, N, g[i])


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

shell_sort(B, n)
print(cnt)
[print(B[i]) for i in range(n)]
