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

    return A, cnt


def shell_sort(A, n):
    cnt = 0
    g = 1
    G = []
    while g <= n:
        G.append(g)
        g = 3 * g + 1
    G.reverse()
    m = len(G)

    for g in G:
        A, cnt = insertion_sort(A, n, g, cnt)

    return m, G, cnt, A


n = int(input().rstrip())
A = []
for _ in range(n):
    A.append(int(input().rstrip()))

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

print(m)
print(' '.join(list(map(str, G))))
print(cnt)
print('\n'.join(list(map(str, A)))) def insertion_sort(A, n, g, 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]
            cnt += 1
            j -= g
        A[j+g] = v

    return A, cnt insertion_sort for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            cnt += 1
            j -= g
        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]
            cnt += 1
            j -= g
         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 cnt += 1 cnt 1 j -= g j g 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):
    cnt = 0
    g = 1
    G = []
    while g <= n:
        G.append(g)
        g = 3 * g + 1
    G.reverse()
    m = len(G)

    for g in G:
        A, cnt = insertion_sort(A, n, g, cnt)

    return m, G, cnt, A shell_sort cnt = 0 cnt 0 g = 1 g 1 G = [] G [] while g <= n:
        G.append(g)
        g = 3 * g + 1
     g <= n g n G.append(g) G.append G append g g = 3 * g + 1 g 3 * g + 1 3 * g 3 g 1 G.reverse() G.reverse G reverse m = len(G) m len(G) len G for g in G:
        A, cnt = insertion_sort(A, n, g, cnt)

     g G A, cnt = insertion_sort(A, n, g, cnt) A insertion_sort(A, n, g, cnt) insertion_sort A n g cnt cnt return m, G, cnt, A return m, G, cnt, A m G cnt A A A n n n = int(input().rstrip()) n int(input().rstrip()) int input().rstrip() ().rstrip () input rstrip A = [] A [] for _ in range(n):
    A.append(int(input().rstrip())) _ range(n) range n A.append(int(input().rstrip())) A.append A append int(input().rstrip()) int input().rstrip() ().rstrip () input rstrip 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(' '.join(list(map(str, G)))) print ' '.join(list(map(str, G))) ' '.join ' ' join list(map(str, G)) list map(str, G) map str G print(cnt) print cnt print('\n'.join(list(map(str, A)))) print '\n'.join(list(map(str, A))) '\n'.join '\n' join list(map(str, A)) list map(str, A) map str A A = [] [] A def insertion_sort(A, n, g, 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]
            cnt += 1
            j -= g
        A[j+g] = v

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

    return A, cnt insertion_sort def shell_sort(A, n):
    cnt = 0
    g = 1
    G = []
    while g <= n:
        G.append(g)
        g = 3 * g + 1
    G.reverse()
    m = len(G)

    for g in G:
        A, cnt = insertion_sort(A, n, g, cnt)

    return m, G, cnt, A def shell_sort(A, n):
    cnt = 0
    g = 1
    G = []
    while g <= n:
        G.append(g)
        g = 3 * g + 1
    G.reverse()
    m = len(G)

    for g in G:
        A, cnt = insertion_sort(A, n, g, cnt)

    return m, G, cnt, A shell_sort A = shell_sort(A, n) shell_sort(A, n) A cnt, A = shell_sort(A, n) shell_sort(A, n) cnt m, G, cnt, A = shell_sort(A, n) shell_sort(A, n) m n = int(input().rstrip()) int(input().rstrip()) n G, cnt, A = shell_sort(A, n) shell_sort(A, n) G
def insertion_sort(A, n, g, 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]
            cnt += 1
            j -= g
        A[j+g] = v

    return A, cnt


def shell_sort(A, n):
    cnt = 0
    g = 1
    G = []
    while g <= n:
        G.append(g)
        g = 3 * g + 1
    G.reverse()
    m = len(G)

    for g in G:
        A, cnt = insertion_sort(A, n, g, cnt)

    return m, G, cnt, A


n = int(input().rstrip())
A = []
for _ in range(n):
    A.append(int(input().rstrip()))

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

print(m)
print(' '.join(list(map(str, G))))
print(cnt)
print('\n'.join(list(map(str, A))))
