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


def shellSort(A, n):
    global cnt
    m = 0
    k = 1
    G = []
    while k <= n:
        G.append(k)
        m +=1
        k = k + 3**m

    G .reverse()

    for i in range(m):
        insertionSort(A, n, G[i])

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


m = int(input())
lst = []
for i in range(m):
    lst.append(int(input()))

cnt = 0
shellSort(lst, m) def insertionSort(A, n, g):
    global 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]
            j = j - g
            cnt += 1
        A[j+g] = v insertionSort global 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]
            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 = 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 = j - g j j - g j g cnt += 1 cnt 1 A[j+g] = v A[j+g] A j+g j g v A A n n g g def shellSort(A, n):
    global cnt
    m = 0
    k = 1
    G = []
    while k <= n:
        G.append(k)
        m +=1
        k = k + 3**m

    G .reverse()

    for i in range(m):
        insertionSort(A, n, G[i])

    print(m)
    print(*G)
    print(cnt)
    for j in A:
        print(j) shellSort global cnt m = 0 m 0 k = 1 k 1 G = [] G [] while k <= n:
        G.append(k)
        m +=1
        k = k + 3**m

     k <= n k n G.append(k) G.append G append k m +=1 m 1 k = k + 3**m k k + 3**m k 3**m 3 m G .reverse() G .reverse G reverse for i in range(m):
        insertionSort(A, n, G[i])

     i range(m) range m insertionSort(A, n, G[i]) insertionSort A n G[i] G i print(m) print m print(*G) print *G G print(cnt) print cnt for j in A:
        print(j) j A print(j) print j A A n n m = int(input()) m int(input()) int input() input lst = [] lst [] for i in range(m):
    lst.append(int(input())) i range(m) range m lst.append(int(input())) lst.append lst append int(input()) int input() input cnt = 0 cnt 0 shellSort(lst, m) shellSort lst m def insertionSort(A, n, g):
    global 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]
            j = j - g
            cnt += 1
        A[j+g] = v def insertionSort(A, n, g):
    global 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]
            j = j - g
            cnt += 1
        A[j+g] = v insertionSort m = int(input()) int(input()) m cnt = 0 0 cnt lst = [] [] lst def shellSort(A, n):
    global cnt
    m = 0
    k = 1
    G = []
    while k <= n:
        G.append(k)
        m +=1
        k = k + 3**m

    G .reverse()

    for i in range(m):
        insertionSort(A, n, G[i])

    print(m)
    print(*G)
    print(cnt)
    for j in A:
        print(j) def shellSort(A, n):
    global cnt
    m = 0
    k = 1
    G = []
    while k <= n:
        G.append(k)
        m +=1
        k = k + 3**m

    G .reverse()

    for i in range(m):
        insertionSort(A, n, G[i])

    print(m)
    print(*G)
    print(cnt)
    for j in A:
        print(j) shellSort
def insertionSort(A, n, g):
    global 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]
            j = j - g
            cnt += 1
        A[j+g] = v


def shellSort(A, n):
    global cnt
    m = 0
    k = 1
    G = []
    while k <= n:
        G.append(k)
        m +=1
        k = k + 3**m

    G .reverse()

    for i in range(m):
        insertionSort(A, n, G[i])

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


m = int(input())
lst = []
for i in range(m):
    lst.append(int(input()))

cnt = 0
shellSort(lst, m)
