import sys

if sys.version_info[0]>=3: raw_input=input



def insertionSort(a,g):

    global cnt

    for i in range(g,len(a)):

        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):

    global cnt

    cnt = 0

    g = []

    h = 1

    while h <= len(a):

        g.append(h)

        h = 3*h+1

    g.reverse()

    m = len(g)

    print(m)

    print((' '.join(map(str,g))))

    for i in range(m):

        insertionSort(a,g[i])





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

shellSort(a)

print(cnt)

for e in a: print(e)
import math





def insertionsort(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 = j - g

            cnt += 1

        a[j + g] = v

    return cnt





def shellsort(a, n):

    g = []

    gap = 1

    while gap <= math.ceil(n / 3):

        g.append(gap)

        gap = 3 * gap + 1

    g = g[::-1]

    m = len(g)

    print(m)

    print((*g))

    cnt = 0

    for i in range(m):

        cnt += insertionsort(a, n, g[i])

    print(cnt)



n = int(eval(input()))

a = []

for i in range(n):

    a.append(int(eval(input())))

shellsort(a, n)

print(("\n".join(map(str, a))))
import sys

if sys.version_info[0] >= 3:
    raw_input = input


def insertionSort(a, g):
    global cnt
    for i in range(g, len(a)):
        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):
    global cnt
    cnt = 0
    g = []
    h = 1
    while h <= len(a):
        g.append(h)
        h = 3 * h + 1
    g.reverse()
    m = len(g)
    print(m)
    print((" ".join(map(str, g))))
    for i in range(m):
        insertionSort(a, g[i])


a = [int(input()) for i in range(int(input()))]
shellSort(a)
print(cnt)
for e in a:
    print(e)

import math


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


def shellsort(a, n):
    g = []
    gap = 1
    while gap <= math.ceil(n / 3):
        g.append(gap)
        gap = 3 * gap + 1
    g = g[::-1]
    m = len(g)
    print(m)
    print((*g))
    cnt = 0
    for i in range(m):
        cnt += insertionsort(a, n, g[i])
    print(cnt)


n = int(eval(input()))
a = []
for i in range(n):
    a.append(int(eval(input())))
shellsort(a, n)
print(("\n".join(map(str, a))))

-import sys - -if sys.version_info[0] >= 3: -    raw_input = input +import math -def insertionSort(a, g): -    global cnt -    for i in range(g, len(a)): +def insertionsort(a, n, g): +    cnt = 0 +    for i in range(g, n): -            a[j + g] = v +        a[j + g] = v +    return cnt -def shellSort(a): -    global cnt -    cnt = 0 +def shellsort(a, n): -    h = 1 -    while h <= len(a): -        g.append(h) -        h = 3 * h + 1 -    g.reverse() +    gap = 1 +    while gap <= math.ceil(n / 3): +        g.append(gap) +        gap = 3 * gap + 1 +    g = g[::-1] -    print((" ".join(map(str, g)))) +    print((*g)) +    cnt = 0 -        insertionSort(a, g[i]) +        cnt += insertionsort(a, n, g[i]) +    print(cnt) -a = [int(input()) for i in range(int(input()))] -shellSort(a) -print(cnt) -for e in a: -    print(e) +n = int(eval(input())) +a = [] +for i in range(n): +    a.append(int(eval(input()))) +shellsort(a, n) +print(("\n".join(map(str, a))))