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

def insertionSort(A, n, g, _count):
    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
            _count += 1
        A[j+g] = v
    return _count

def shellSort(A, n):
    count = 0
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3*h + 1
    m = len(G)
    for i in reversed(range(m)):
        count = insertionSort(A, n, G[i], count)
    return m, G, count

m, G, count = shellSort(A_n, n)
print(m)
print_G_str = ''
for i in range(m):
    print_G_str += str(G[m - 1 - i])
    if i < m - 1:
        print_G_str += ' '
print(print_G_str)
print(count)
for A in A_n:
    print(A)
 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_n = [int(input()) for i in range(n)] A_n [int(input()) for i in range(n)] def insertionSort(A, n, g, _count):
    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
            _count += 1
        A[j+g] = v
    return _count insertionSort 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
            _count += 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
            _count += 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 _count += 1 _count 1 A[j+g] = v A[j+g] A j+g j g v return _count _count A A n n g g _count _count def shellSort(A, n):
    count = 0
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3*h + 1
    m = len(G)
    for i in reversed(range(m)):
        count = insertionSort(A, n, G[i], count)
    return m, G, count shellSort count = 0 count 0 h = 1 h 1 G = [] G [] 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 m = len(G) m len(G) len G for i in reversed(range(m)):
        count = insertionSort(A, n, G[i], count)
     i reversed(range(m)) reversed range(m) range m count = insertionSort(A, n, G[i], count) count insertionSort(A, n, G[i], count) insertionSort A n G[i] G i count return m, G, count return m, G, count m G count A A n n m, G, count = shellSort(A_n, n) m shellSort(A_n, n) shellSort A_n n G count print(m) print m print_G_str = '' print_G_str '' for i in range(m):
    print_G_str += str(G[m - 1 - i])
    if i < m - 1:
        print_G_str += ' ' i range(m) range m print_G_str += str(G[m - 1 - i]) print_G_str str(G[m - 1 - i]) str G[m - 1 - i] G m - 1 - i m - 1 m 1 i if i < m - 1:
        print_G_str += ' ' i < m - 1 i m - 1 m 1 print_G_str += ' ' print_G_str ' ' print(print_G_str) print print_G_str print(count) print count for A in A_n:
    print(A) A A_n print(A) print A count = shellSort(A_n, n) shellSort(A_n, n) count print_G_str += str(G[m - 1 - i]) str(G[m - 1 - i]) print_G_str print_G_str += ' ' ' ' print_G_str def insertionSort(A, n, g, _count):
    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
            _count += 1
        A[j+g] = v
    return _count def insertionSort(A, n, g, _count):
    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
            _count += 1
        A[j+g] = v
    return _count insertionSort G, count = shellSort(A_n, n) shellSort(A_n, n) G print_G_str = '' '' print_G_str A_n = [int(input()) for i in range(n)] [int(input()) for i in range(n)] A_n def shellSort(A, n):
    count = 0
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3*h + 1
    m = len(G)
    for i in reversed(range(m)):
        count = insertionSort(A, n, G[i], count)
    return m, G, count def shellSort(A, n):
    count = 0
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3*h + 1
    m = len(G)
    for i in reversed(range(m)):
        count = insertionSort(A, n, G[i], count)
    return m, G, count shellSort n = int(input()) int(input()) n m, G, count = shellSort(A_n, n) shellSort(A_n, n) m
n = int(input())
A_n = [int(input()) for i in range(n)]

def insertionSort(A, n, g, _count):
    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
            _count += 1
        A[j+g] = v
    return _count

def shellSort(A, n):
    count = 0
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3*h + 1
    m = len(G)
    for i in reversed(range(m)):
        count = insertionSort(A, n, G[i], count)
    return m, G, count

m, G, count = shellSort(A_n, n)
print(m)
print_G_str = ''
for i in range(m):
    print_G_str += str(G[m - 1 - i])
    if i < m - 1:
        print_G_str += ' '
print(print_G_str)
print(count)
for A in A_n:
    print(A)

