def insertion_sort(a, n, g, 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
    return cnt

def shell_sort(a, n):
    cnt = 0
    h = 1
    g = []
    while h <= n:
        g.insert(0, h)
        h = 3 * h + 1

    for i in range(len(g)):
        if g[i] <= len(a):
            cnt = insertion_sort(a, n, g[i], cnt)

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


n = int(input())
a = [int(input()) for _ in range(n)]

shell_sort(a, n)
for num in a:
    print(num)
 def insertion_sort(a, n, g, 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
    return cnt insertion_sort 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 return cnt cnt a a n n g g cnt cnt def shell_sort(a, n):
    cnt = 0
    h = 1
    g = []
    while h <= n:
        g.insert(0, h)
        h = 3 * h + 1

    for i in range(len(g)):
        if g[i] <= len(a):
            cnt = insertion_sort(a, n, g[i], cnt)

    print(len(g))
    print(' '.join(map(str, g)))
    print(cnt) shell_sort cnt = 0 cnt 0 h = 1 h 1 g = [] g [] while h <= n:
        g.insert(0, h)
        h = 3 * h + 1

     h <= n h n g.insert(0, h) g.insert g insert 0 h h = 3 * h + 1 h 3 * h + 1 3 * h 3 h 1 for i in range(len(g)):
        if g[i] <= len(a):
            cnt = insertion_sort(a, n, g[i], cnt)

     i range(len(g)) range len(g) len g if g[i] <= len(a):
            cnt = insertion_sort(a, n, g[i], cnt)

     g[i] <= len(a) g[i] g i len(a) len a cnt = insertion_sort(a, n, g[i], cnt) cnt insertion_sort(a, n, g[i], cnt) insertion_sort a n g[i] g i cnt print(len(g)) print len(g) len g print(' '.join(map(str, g))) print ' '.join(map(str, g)) ' '.join ' ' join map(str, g) map str g print(cnt) print cnt a a n n n = int(input()) n int(input()) int input() input int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input a = [int(input()) for _ in range(n)] a [int(input()) for _ in range(n)] shell_sort(a, n) shell_sort a n for num in a:
    print(num) num a print(num) print num def insertion_sort(a, n, g, 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
    return cnt def insertion_sort(a, n, g, 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
    return cnt insertion_sort def shell_sort(a, n):
    cnt = 0
    h = 1
    g = []
    while h <= n:
        g.insert(0, h)
        h = 3 * h + 1

    for i in range(len(g)):
        if g[i] <= len(a):
            cnt = insertion_sort(a, n, g[i], cnt)

    print(len(g))
    print(' '.join(map(str, g)))
    print(cnt) def shell_sort(a, n):
    cnt = 0
    h = 1
    g = []
    while h <= n:
        g.insert(0, h)
        h = 3 * h + 1

    for i in range(len(g)):
        if g[i] <= len(a):
            cnt = insertion_sort(a, n, g[i], cnt)

    print(len(g))
    print(' '.join(map(str, g)))
    print(cnt) shell_sort n = int(input()) int(input()) n a = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] a
def insertion_sort(a, n, g, 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
    return cnt

def shell_sort(a, n):
    cnt = 0
    h = 1
    g = []
    while h <= n:
        g.insert(0, h)
        h = 3 * h + 1

    for i in range(len(g)):
        if g[i] <= len(a):
            cnt = insertion_sort(a, n, g[i], cnt)

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


n = int(input())
a = [int(input()) for _ in range(n)]

shell_sort(a, n)
for num in a:
    print(num)

