def insertion_sort(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 shell_sort(A, n):
    cnt = 0
    G = [1]
    for i in range(1, 100):
        # https://web.archive.org/web/20170212072405/http://www.programming-magic.com/20100507074241/
        # 間隔
        delta = 4 ** i + 3 * 2 ** (i - 1) + 1
        if delta >= n:
            break
        G.append(delta)
    G.reverse()
    m = len(G)
    for i in range(m):
        cnt += insertion_sort(A, n, G[i])
    return m, G, cnt
n = int(input())
A = [int(input()) for _ in range(n)]
m, G, cnt = shell_sort(A, n)
print(m)
print(*G)
print(cnt)
print(*A, sep='\n') def insertion_sort(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 insertion_sort 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 shell_sort(A, n):
    cnt = 0
    G = [1]
    for i in range(1, 100):
        # https://web.archive.org/web/20170212072405/http://www.programming-magic.com/20100507074241/
        # 間隔
        delta = 4 ** i + 3 * 2 ** (i - 1) + 1
        if delta >= n:
            break
        G.append(delta)
    G.reverse()
    m = len(G)
    for i in range(m):
        cnt += insertion_sort(A, n, G[i])
    return m, G, cnt shell_sort cnt = 0 cnt 0 G = [1] G [1] 1 for i in range(1, 100):
        # https://web.archive.org/web/20170212072405/http://www.programming-magic.com/20100507074241/
        # 間隔
        delta = 4 ** i + 3 * 2 ** (i - 1) + 1
        if delta >= n:
            break
        G.append(delta)
     i range(1, 100) range 1 100 delta = 4 ** i + 3 * 2 ** (i - 1) + 1 delta 4 ** i + 3 * 2 ** (i - 1) + 1 4 ** i + 3 * 2 ** (i - 1) 4 ** i 4 i 3 * 2 ** (i - 1) 3 2 ** (i - 1) 2 i - 1 i 1 1 if delta >= n:
            break
         delta >= n delta n break G.append(delta) G.append G append delta G.reverse() G.reverse G reverse m = len(G) m len(G) len G for i in range(m):
        cnt += insertion_sort(A, n, G[i])
     i range(m) range m cnt += insertion_sort(A, n, G[i]) cnt insertion_sort(A, n, G[i]) insertion_sort A n G[i] G i return m, G, cnt return m, G, cnt m G cnt A A n n n = int(input()) n int(input()) int input() input int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input A = [int(input()) for _ in range(n)] A [int(input()) for _ in range(n)] m, G, cnt = shell_sort(A, n) m shell_sort(A, n) shell_sort A n G cnt print(m) print m print(*G) print *G G print(cnt) print cnt print(*A, sep='\n') print *A A sep='\n' sep '\n' def shell_sort(A, n):
    cnt = 0
    G = [1]
    for i in range(1, 100):
        # https://web.archive.org/web/20170212072405/http://www.programming-magic.com/20100507074241/
        # 間隔
        delta = 4 ** i + 3 * 2 ** (i - 1) + 1
        if delta >= n:
            break
        G.append(delta)
    G.reverse()
    m = len(G)
    for i in range(m):
        cnt += insertion_sort(A, n, G[i])
    return m, G, cnt def shell_sort(A, n):
    cnt = 0
    G = [1]
    for i in range(1, 100):
        # https://web.archive.org/web/20170212072405/http://www.programming-magic.com/20100507074241/
        # 間隔
        delta = 4 ** i + 3 * 2 ** (i - 1) + 1
        if delta >= n:
            break
        G.append(delta)
    G.reverse()
    m = len(G)
    for i in range(m):
        cnt += insertion_sort(A, n, G[i])
    return m, G, cnt shell_sort n = int(input()) int(input()) n G, cnt = shell_sort(A, n) shell_sort(A, n) G cnt = shell_sort(A, n) shell_sort(A, n) cnt A = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] A m, G, cnt = shell_sort(A, n) shell_sort(A, n) m def insertion_sort(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 insertion_sort(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 insertion_sort
def insertion_sort(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 shell_sort(A, n):
    cnt = 0
    G = [1]
    for i in range(1, 100):
        # https://web.archive.org/web/20170212072405/http://www.programming-magic.com/20100507074241/
        # 間隔
        delta = 4 ** i + 3 * 2 ** (i - 1) + 1
        if delta >= n:
            break
        G.append(delta)
    G.reverse()
    m = len(G)
    for i in range(m):
        cnt += insertion_sort(A, n, G[i])
    return m, G, cnt
n = int(input())
A = [int(input()) for _ in range(n)]
m, G, cnt = shell_sort(A, n)
print(m)
print(*G)
print(cnt)
print(*A, sep='\n')
