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.append(i)
        i = i * 3 + 1
    G_inv = G[::-1]
    for g in G_inv:
        insertion_sort(A, n, g)
    return len(G), G_inv, A

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

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