import math
n = int(input())
li = [int(input()) for i in range(n)]
cnt = 0
def shell_sort(li, n):
    m = math.floor(math.log(2*n+1, 3))
    G = [round((3**i-1)/2) for i in range(m, 0, -1)]
    for i in range(m):
        insertionSort(li, n, G[i])
    return m, G
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

m, G = shell_sort(li, n)

print(m)
strG = [str(i) for i in G]
print(' '.join(strG))
print(cnt)
for i in li:
    print(i) import math math 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 li = [int(input()) for i in range(n)] li [int(input()) for i in range(n)] cnt = 0 cnt 0 def shell_sort(li, n):
    m = math.floor(math.log(2*n+1, 3))
    G = [round((3**i-1)/2) for i in range(m, 0, -1)]
    for i in range(m):
        insertionSort(li, n, G[i])
    return m, G shell_sort m = math.floor(math.log(2*n+1, 3)) m math.floor(math.log(2*n+1, 3)) math.floor math floor math.log(2*n+1, 3) math.log math log 2*n+1 2*n 2 n 1 3 round((3**i-1)/2) for i in range(m, 0, -1) for i in range(m, 0, -1) i range(m, 0, -1) range m 0 -1 for i in range(m, 0, -1) round((3**i-1)/2) round (3**i-1)/2 3**i-1 3**i 3 i 1 2 G = [round((3**i-1)/2) for i in range(m, 0, -1)] G [round((3**i-1)/2) for i in range(m, 0, -1)] for i in range(m):
        insertionSort(li, n, G[i])
     i range(m) range m insertionSort(li, n, G[i]) insertionSort li n G[i] G i return m, G return m, G m G li li n n 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 m, G = shell_sort(li, n) m shell_sort(li, n) shell_sort li n G print(m) print m str(i) for i in G for i in G i G for i in G str(i) str i strG = [str(i) for i in G] strG [str(i) for i in G] print(' '.join(strG)) print ' '.join(strG) ' '.join ' ' join strG print(cnt) print cnt for i in li:
    print(i) i li print(i) print i cnt = 0 0 cnt G = shell_sort(li, n) shell_sort(li, n) G 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 n = int(input()) int(input()) n m, G = shell_sort(li, n) shell_sort(li, n) m strG = [str(i) for i in G] [str(i) for i in G] strG li = [int(input()) for i in range(n)] [int(input()) for i in range(n)] li def shell_sort(li, n):
    m = math.floor(math.log(2*n+1, 3))
    G = [round((3**i-1)/2) for i in range(m, 0, -1)]
    for i in range(m):
        insertionSort(li, n, G[i])
    return m, G def shell_sort(li, n):
    m = math.floor(math.log(2*n+1, 3))
    G = [round((3**i-1)/2) for i in range(m, 0, -1)]
    for i in range(m):
        insertionSort(li, n, G[i])
    return m, G shell_sort
import math
n = int(input())
li = [int(input()) for i in range(n)]
cnt = 0
def shell_sort(li, n):
    m = math.floor(math.log(2*n+1, 3))
    G = [round((3**i-1)/2) for i in range(m, 0, -1)]
    for i in range(m):
        insertionSort(li, n, G[i])
    return m, G
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

m, G = shell_sort(li, n)

print(m)
strG = [str(i) for i in G]
print(' '.join(strG))
print(cnt)
for i in li:
    print(i)
