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


def shell_sort(A, n):
    G = []
    i = 1
    while i <= n:
        G[0:0] = [i]
        i = i * 3 + 1
    for g in G:
        insertion_sort(A, n, g)
    return len(G), G

N = int(input())
a = [int(input()) for i in range(N)]
cnt = 0
m, Gl = shell_sort(a, N)
print(m, ' '.join(str(g) for g in Gl), cnt, '\n'.join(str(e) for e in a), sep='\n') def insertion_sort(A, n, g):
    global cnt
    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 -= g
            cnt += 1
        A[j + g] = v insertion_sort global cnt 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 -= 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 def shell_sort(A, n):
    G = []
    i = 1
    while i <= n:
        G[0:0] = [i]
        i = i * 3 + 1
    for g in G:
        insertion_sort(A, n, g)
    return len(G), G shell_sort G = [] G [] i = 1 i 1 while i <= n:
        G[0:0] = [i]
        i = i * 3 + 1
     i <= n i n G[0:0] = [i] G[0:0] G 0:0 0 0 [i] i i = i * 3 + 1 i i * 3 + 1 i * 3 i 3 1 for g in G:
        insertion_sort(A, n, g)
     g G insertion_sort(A, n, g) insertion_sort A n g return len(G), G return len(G), G len(G) len G G A A n 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 a = [int(input()) for i in range(N)] a [int(input()) for i in range(N)] cnt = 0 cnt 0 m, Gl = shell_sort(a, N) m shell_sort(a, N) shell_sort a N Gl print(m, ' '.join(str(g) for g in Gl), cnt, '\n'.join(str(e) for e in a), sep='\n') print m ' '.join(str(g) for g in Gl) ' '.join ' ' join str(g) str g cnt '\n'.join(str(e) for e in a) '\n'.join '\n' join str(e) str e sep='\n' sep '\n' N = int(input()) int(input()) N def insertion_sort(A, n, g):
    global cnt
    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 -= g
            cnt += 1
        A[j + g] = v def insertion_sort(A, n, g):
    global cnt
    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 -= g
            cnt += 1
        A[j + g] = v insertion_sort a = [int(input()) for i in range(N)] [int(input()) for i in range(N)] a def shell_sort(A, n):
    G = []
    i = 1
    while i <= n:
        G[0:0] = [i]
        i = i * 3 + 1
    for g in G:
        insertion_sort(A, n, g)
    return len(G), G def shell_sort(A, n):
    G = []
    i = 1
    while i <= n:
        G[0:0] = [i]
        i = i * 3 + 1
    for g in G:
        insertion_sort(A, n, g)
    return len(G), G shell_sort Gl = shell_sort(a, N) shell_sort(a, N) Gl m, Gl = shell_sort(a, N) shell_sort(a, N) m cnt = 0 0 cnt
def insertion_sort(A, n, g):
    global cnt
    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 -= g
            cnt += 1
        A[j + g] = v


def shell_sort(A, n):
    G = []
    i = 1
    while i <= n:
        G[0:0] = [i]
        i = i * 3 + 1
    for g in G:
        insertion_sort(A, n, g)
    return len(G), G

N = int(input())
a = [int(input()) for i in range(N)]
cnt = 0
m, Gl = shell_sort(a, N)
print(m, ' '.join(str(g) for g in Gl), cnt, '\n'.join(str(e) for e in a), sep='\n')