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

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

i = 0
g = [1]
while 3*g[i]+1 < n:
    g.append(3*g[i]+1)
    i += 1
g.reverse()
m = len(g)

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

print(m)
print(*g)
print(cnt)
print(*a, sep="\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 cnt = 0 cnt 0 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 a = [int(input()) for i in range(n)] a [int(input()) for i in range(n)] i = 0 i 0 g = [1] g [1] 1 while 3*g[i]+1 < n:
    g.append(3*g[i]+1)
    i += 1 3*g[i]+1 < n 3*g[i]+1 3*g[i] 3 g[i] g i 1 n g.append(3*g[i]+1) g.append g append 3*g[i]+1 3*g[i] 3 g[i] g i 1 i += 1 i 1 g.reverse() g.reverse g reverse m = len(g) m len(g) len g 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 print(*a, sep="\n") print *a a sep="\n" sep "\n" cnt = 0 0 cnt g = [1] [1] g m = len(g) len(g) m i += 1 1 i 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 i = 0 0 i n = int(input()) int(input()) n a = [int(input()) for i in range(n)] [int(input()) for i in range(n)] a
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

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

i = 0
g = [1]
while 3*g[i]+1 < n:
    g.append(3*g[i]+1)
    i += 1
g.reverse()
m = len(g)

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

print(m)
print(*g)
print(cnt)
print(*a, sep="\n")