import copy


def insertion_sort(A_, n, g, cnt):
    A = copy.copy(A_)
    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
    return A, cnt


def shell_sort(A_, n):
    A = copy.copy(A_)
    cnt = 0
    G = [(3 ** i - 1) // 2 for i in reversed(range(1, 14))
         if (3 ** i - 1) // 2 <= n]
    m = len(G)
    for i in range(m):
        A, cnt = insertion_sort(A, n, G[i], cnt)
    return m, G, cnt, A


n = int(input())
A = [int(input()) for i in range(n)]
m, G, cnt, A = shell_sort(A, n)

print(m)
print(*G)
print(cnt)
for a in A:
    print(a)
 import copy copy def insertion_sort(A_, n, g, cnt):
    A = copy.copy(A_)
    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
    return A, cnt insertion_sort A = copy.copy(A_) A copy.copy(A_) copy.copy copy copy A_ 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 return A, cnt return A, cnt A cnt A_ A_ n n g g cnt cnt def shell_sort(A_, n):
    A = copy.copy(A_)
    cnt = 0
    G = [(3 ** i - 1) // 2 for i in reversed(range(1, 14))
         if (3 ** i - 1) // 2 <= n]
    m = len(G)
    for i in range(m):
        A, cnt = insertion_sort(A, n, G[i], cnt)
    return m, G, cnt, A shell_sort A = copy.copy(A_) A copy.copy(A_) copy.copy copy copy A_ cnt = 0 cnt 0 (3 ** i - 1) // 2 for i in reversed(range(1, 14))
         if (3 ** i - 1) // 2 <= n for i in reversed(range(1, 14))
         if (3 ** i - 1) // 2 <= n i reversed(range(1, 14)) reversed range(1, 14) range 1 14 (3 ** i - 1) // 2 <= n (3 ** i - 1) // 2 3 ** i - 1 3 ** i 3 i 1 2 n if (3 ** i - 1) // 2 <= n (3 ** i - 1) // 2 3 ** i - 1 3 ** i 3 i 1 2 G = [(3 ** i - 1) // 2 for i in reversed(range(1, 14))
         if (3 ** i - 1) // 2 <= n] G [(3 ** i - 1) // 2 for i in reversed(range(1, 14))
         if (3 ** i - 1) // 2 <= n] m = len(G) m len(G) len G for i in range(m):
        A, cnt = insertion_sort(A, n, G[i], cnt)
     i range(m) range m A, cnt = insertion_sort(A, n, G[i], cnt) A insertion_sort(A, n, G[i], cnt) insertion_sort A n G[i] G i cnt cnt return m, G, cnt, A return m, G, cnt, A m G cnt 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)] m, G, cnt, A = shell_sort(A, n) m shell_sort(A, n) shell_sort A n G cnt A print(m) print m print(*G) print *G G print(cnt) print cnt for a in A:
    print(a) a A print(a) print a m, G, cnt, 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 cnt, A = shell_sort(A, n) shell_sort(A, n) cnt A = shell_sort(A, n) shell_sort(A, n) A def shell_sort(A_, n):
    A = copy.copy(A_)
    cnt = 0
    G = [(3 ** i - 1) // 2 for i in reversed(range(1, 14))
         if (3 ** i - 1) // 2 <= n]
    m = len(G)
    for i in range(m):
        A, cnt = insertion_sort(A, n, G[i], cnt)
    return m, G, cnt, A def shell_sort(A_, n):
    A = copy.copy(A_)
    cnt = 0
    G = [(3 ** i - 1) // 2 for i in reversed(range(1, 14))
         if (3 ** i - 1) // 2 <= n]
    m = len(G)
    for i in range(m):
        A, cnt = insertion_sort(A, n, G[i], cnt)
    return m, G, cnt, A shell_sort n = int(input()) int(input()) n def insertion_sort(A_, n, g, cnt):
    A = copy.copy(A_)
    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
    return A, cnt def insertion_sort(A_, n, g, cnt):
    A = copy.copy(A_)
    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
    return A, cnt insertion_sort G, cnt, A = shell_sort(A, n) shell_sort(A, n) G
import copy


def insertion_sort(A_, n, g, cnt):
    A = copy.copy(A_)
    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
    return A, cnt


def shell_sort(A_, n):
    A = copy.copy(A_)
    cnt = 0
    G = [(3 ** i - 1) // 2 for i in reversed(range(1, 14))
         if (3 ** i - 1) // 2 <= n]
    m = len(G)
    for i in range(m):
        A, cnt = insertion_sort(A, n, G[i], cnt)
    return m, G, cnt, A


n = int(input())
A = [int(input()) for i in range(n)]
m, G, cnt, A = shell_sort(A, n)

print(m)
print(*G)
print(cnt)
for a in A:
    print(a)

