
def InsertionSort(A, n, g):
    cnt = 0

    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 cnt

def ShellSort(A, n):
    total_cnt = 0

    G = [1]
    span = 4

    while span < len(A):
        G.append(span)
        span = span * 3 + 1

    G.reverse()

    m = len(G)

    for i in range(m):
        total_cnt += InsertionSort(A, n, G[i])

    return m, G, total_cnt

n = int(input())
A = []

for i in range(n):
    A.append(int(input()))

m, G, cnt = ShellSort(A, n)

print(m)
print(*G)
print(cnt)

for a in A:
    print(a) def InsertionSort(A, n, g):
    cnt = 0

    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 cnt InsertionSort cnt = 0 cnt 0 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 cnt cnt A A n n g g def ShellSort(A, n):
    total_cnt = 0

    G = [1]
    span = 4

    while span < len(A):
        G.append(span)
        span = span * 3 + 1

    G.reverse()

    m = len(G)

    for i in range(m):
        total_cnt += InsertionSort(A, n, G[i])

    return m, G, total_cnt ShellSort total_cnt = 0 total_cnt 0 G = [1] G [1] 1 span = 4 span 4 while span < len(A):
        G.append(span)
        span = span * 3 + 1

     span < len(A) span len(A) len A G.append(span) G.append G append span span = span * 3 + 1 span span * 3 + 1 span * 3 span 3 1 G.reverse() G.reverse G reverse m = len(G) m len(G) len G for i in range(m):
        total_cnt += InsertionSort(A, n, G[i])

     i range(m) range m total_cnt += InsertionSort(A, n, G[i]) total_cnt InsertionSort(A, n, G[i]) InsertionSort A n G[i] G i return m, G, total_cnt return m, G, total_cnt m G total_cnt A A n n 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 m, G, cnt = ShellSort(A, n) m ShellSort(A, n) ShellSort A n G cnt 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 n = int(input()) int(input()) n G, cnt = ShellSort(A, n) ShellSort(A, n) G def InsertionSort(A, n, g):
    cnt = 0

    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 cnt def InsertionSort(A, n, g):
    cnt = 0

    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 cnt InsertionSort cnt = ShellSort(A, n) ShellSort(A, n) cnt m, G, cnt = ShellSort(A, n) ShellSort(A, n) m A = [] [] A def ShellSort(A, n):
    total_cnt = 0

    G = [1]
    span = 4

    while span < len(A):
        G.append(span)
        span = span * 3 + 1

    G.reverse()

    m = len(G)

    for i in range(m):
        total_cnt += InsertionSort(A, n, G[i])

    return m, G, total_cnt def ShellSort(A, n):
    total_cnt = 0

    G = [1]
    span = 4

    while span < len(A):
        G.append(span)
        span = span * 3 + 1

    G.reverse()

    m = len(G)

    for i in range(m):
        total_cnt += InsertionSort(A, n, G[i])

    return m, G, total_cnt ShellSort

def InsertionSort(A, n, g):
    cnt = 0

    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 cnt

def ShellSort(A, n):
    total_cnt = 0

    G = [1]
    span = 4

    while span < len(A):
        G.append(span)
        span = span * 3 + 1

    G.reverse()

    m = len(G)

    for i in range(m):
        total_cnt += InsertionSort(A, n, G[i])

    return m, G, total_cnt

n = int(input())
A = []

for i in range(n):
    A.append(int(input()))

m, G, cnt = ShellSort(A, n)

print(m)
print(*G)
print(cnt)

for a in A:
    print(a)