n = int(input())
a = []
cnt = 0
for i in range(n):
    a.append(int(input()))

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 = cnt + 1
        a[j+g] = v

g = []
g.append(1)
m = 0
while g[m] < n:
    if n > 3 * g[m] + 1:
        m = m + 1
        g.append(3 * g[m-1] + 1)
    else:
        break
m = m + 1
g.reverse()

for i in range(m):
    insertionSort(a,n,g[i])

print(m)
print(*g)
print(cnt)
for i in range(n):
    print(a[i])

 n = int(input()) n int(input()) int input() input a = [] a [] cnt = 0 cnt 0 for i in range(n):
    a.append(int(input())) i range(n) range n a.append(int(input())) a.append a append int(input()) int input() input 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 = 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 = 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 = 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 = cnt + 1 cnt cnt + 1 cnt 1 a[j+g] = v a[j+g] a j+g j g v a a n n g g g = [] g [] g.append(1) g.append g append 1 m = 0 m 0 while g[m] < n:
    if n > 3 * g[m] + 1:
        m = m + 1
        g.append(3 * g[m-1] + 1)
    else:
        break g[m] < n g[m] g m n if n > 3 * g[m] + 1:
        m = m + 1
        g.append(3 * g[m-1] + 1)
    else:
        break n > 3 * g[m] + 1 n 3 * g[m] + 1 3 * g[m] 3 g[m] g m 1 m = m + 1 m m + 1 m 1 g.append(3 * g[m-1] + 1) g.append g append 3 * g[m-1] + 1 3 * g[m-1] 3 g[m-1] g m-1 m 1 1 break m = m + 1 m m + 1 m 1 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 i in range(n):
    print(a[i]) i range(n) range n print(a[i]) print a[i] a i m = m + 1 m + 1 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 = 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 = cnt + 1
        a[j+g] = v insertionSort g = [] [] g m = 0 0 m cnt = 0 0 cnt a = [] [] a m = m + 1 m + 1 m n = int(input()) int(input()) n
n = int(input())
a = []
cnt = 0
for i in range(n):
    a.append(int(input()))

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 = cnt + 1
        a[j+g] = v

g = []
g.append(1)
m = 0
while g[m] < n:
    if n > 3 * g[m] + 1:
        m = m + 1
        g.append(3 * g[m-1] + 1)
    else:
        break
m = m + 1
g.reverse()

for i in range(m):
    insertionSort(a,n,g[i])

print(m)
print(*g)
print(cnt)
for i in range(n):
    print(a[i])


