import math


def print_list_split_whitespace(a):
    for x in a[:-1]:
        print(x, end=' ')
    print(a[-1])


def insertion_sort(a, n, g, cnt):
    for i in range(g, n, 1):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j -= g
            cnt += 1
        a[j+g] = v
    return cnt


def shell_sort(a, n):
    cnt = 0
    m = math.floor(math.log(2 * n + 1, 3))
    print(m)
    gs = [1]
    for i in range(1, m, 1):
        gs.append(gs[i - 1] * 3 + 1)
    gs.reverse()
    print_list_split_whitespace(gs)

    for i in range(m):
        cnt = insertion_sort(a, n, gs[i], cnt)
    print(cnt)


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

shell_sort(a, n)

for x in a:
    print(x) import math math def print_list_split_whitespace(a):
    for x in a[:-1]:
        print(x, end=' ')
    print(a[-1]) print_list_split_whitespace for x in a[:-1]:
        print(x, end=' ')
     x a[:-1] a :-1 -1 print(x, end=' ') print x end=' ' end ' ' print(a[-1]) print a[-1] a -1 a a def insertion_sort(a, n, g, cnt):
    for i in range(g, n, 1):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j -= g
            cnt += 1
        a[j+g] = v
    return cnt insertion_sort for i in range(g, n, 1):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j -= g
            cnt += 1
        a[j+g] = v
     i range(g, n, 1) range g n 1 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 -= 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 -= 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
    m = math.floor(math.log(2 * n + 1, 3))
    print(m)
    gs = [1]
    for i in range(1, m, 1):
        gs.append(gs[i - 1] * 3 + 1)
    gs.reverse()
    print_list_split_whitespace(gs)

    for i in range(m):
        cnt = insertion_sort(a, n, gs[i], cnt)
    print(cnt) shell_sort cnt = 0 cnt 0 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 print(m) print m gs = [1] gs [1] 1 for i in range(1, m, 1):
        gs.append(gs[i - 1] * 3 + 1)
     i range(1, m, 1) range 1 m 1 gs.append(gs[i - 1] * 3 + 1) gs.append gs append gs[i - 1] * 3 + 1 gs[i - 1] * 3 gs[i - 1] gs i - 1 i 1 3 1 gs.reverse() gs.reverse gs reverse print_list_split_whitespace(gs) print_list_split_whitespace gs for i in range(m):
        cnt = insertion_sort(a, n, gs[i], cnt)
     i range(m) range m cnt = insertion_sort(a, n, gs[i], cnt) cnt insertion_sort(a, n, gs[i], cnt) insertion_sort a n gs[i] gs i cnt print(cnt) print cnt a a n n n = int(input()) n int(input()) int input() input a = [] a [] 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 shell_sort(a, n) shell_sort a n for x in a:
    print(x) x a print(x) print x n = int(input()) int(input()) n a = [] [] a def insertion_sort(a, n, g, cnt):
    for i in range(g, n, 1):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j -= g
            cnt += 1
        a[j+g] = v
    return cnt def insertion_sort(a, n, g, cnt):
    for i in range(g, n, 1):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j -= g
            cnt += 1
        a[j+g] = v
    return cnt insertion_sort def shell_sort(a, n):
    cnt = 0
    m = math.floor(math.log(2 * n + 1, 3))
    print(m)
    gs = [1]
    for i in range(1, m, 1):
        gs.append(gs[i - 1] * 3 + 1)
    gs.reverse()
    print_list_split_whitespace(gs)

    for i in range(m):
        cnt = insertion_sort(a, n, gs[i], cnt)
    print(cnt) def shell_sort(a, n):
    cnt = 0
    m = math.floor(math.log(2 * n + 1, 3))
    print(m)
    gs = [1]
    for i in range(1, m, 1):
        gs.append(gs[i - 1] * 3 + 1)
    gs.reverse()
    print_list_split_whitespace(gs)

    for i in range(m):
        cnt = insertion_sort(a, n, gs[i], cnt)
    print(cnt) shell_sort def print_list_split_whitespace(a):
    for x in a[:-1]:
        print(x, end=' ')
    print(a[-1]) def print_list_split_whitespace(a):
    for x in a[:-1]:
        print(x, end=' ')
    print(a[-1]) print_list_split_whitespace
import math


def print_list_split_whitespace(a):
    for x in a[:-1]:
        print(x, end=' ')
    print(a[-1])


def insertion_sort(a, n, g, cnt):
    for i in range(g, n, 1):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j -= g
            cnt += 1
        a[j+g] = v
    return cnt


def shell_sort(a, n):
    cnt = 0
    m = math.floor(math.log(2 * n + 1, 3))
    print(m)
    gs = [1]
    for i in range(1, m, 1):
        gs.append(gs[i - 1] * 3 + 1)
    gs.reverse()
    print_list_split_whitespace(gs)

    for i in range(m):
        cnt = insertion_sort(a, n, gs[i], cnt)
    print(cnt)


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

shell_sort(a, n)

for x in a:
    print(x)
