#シェルソート
#挿入ソートは、飛び飛びで値を整列すつもの
#それの飛ぶ範囲をどんどん狭めていって正解を出す
import math

def insertionsort(list, length, g, count):
    for i in range(g, length):
        v = list[i]
        j = i - g
        while j >= 0 and list[j] > v:
            list[j+g] = list[j]
            j = j - g
            count += 1
        list[j+g] = v

    return list, count

def shellsort(list, length):
    count = 0
    g_list = [1]
    g_cell = 4
    while g_cell < length:
        g_list.append(g_cell)
        g_cell = g_cell * 3 + 1

    g_list.reverse()
    print(len(g_list))
    result = ''
    for g in g_list:
        result += str(g) + ' '
    print(result[:-1])

    for g in g_list:
        list, count = insertionsort(list, length, g, count)

    return list, count

l = int(input())
target = []
for i in range(l):
    target.append(int(input()))

result, count = shellsort(target, l)
print(count)
for r in result:
    print(r)
 import math math def insertionsort(list, length, g, count):
    for i in range(g, length):
        v = list[i]
        j = i - g
        while j >= 0 and list[j] > v:
            list[j+g] = list[j]
            j = j - g
            count += 1
        list[j+g] = v

    return list, count insertionsort for i in range(g, length):
        v = list[i]
        j = i - g
        while j >= 0 and list[j] > v:
            list[j+g] = list[j]
            j = j - g
            count += 1
        list[j+g] = v

     i range(g, length) range g length v = list[i] v list[i] list i j = i - g j i - g i g while j >= 0 and list[j] > v:
            list[j+g] = list[j]
            j = j - g
            count += 1
         j >= 0 and list[j] > v j >= 0 j 0 list[j] > v list[j] list j v list[j+g] = list[j] list[j+g] list j+g j g list[j] list j j = j - g j j - g j g count += 1 count 1 list[j+g] = v list[j+g] list j+g j g v return list, count return list, count list count list list length length g g count count def shellsort(list, length):
    count = 0
    g_list = [1]
    g_cell = 4
    while g_cell < length:
        g_list.append(g_cell)
        g_cell = g_cell * 3 + 1

    g_list.reverse()
    print(len(g_list))
    result = ''
    for g in g_list:
        result += str(g) + ' '
    print(result[:-1])

    for g in g_list:
        list, count = insertionsort(list, length, g, count)

    return list, count shellsort count = 0 count 0 g_list = [1] g_list [1] 1 g_cell = 4 g_cell 4 while g_cell < length:
        g_list.append(g_cell)
        g_cell = g_cell * 3 + 1

     g_cell < length g_cell length g_list.append(g_cell) g_list.append g_list append g_cell g_cell = g_cell * 3 + 1 g_cell g_cell * 3 + 1 g_cell * 3 g_cell 3 1 g_list.reverse() g_list.reverse g_list reverse print(len(g_list)) print len(g_list) len g_list result = '' result '' for g in g_list:
        result += str(g) + ' '
     g g_list result += str(g) + ' ' result str(g) + ' ' str(g) str g ' ' print(result[:-1]) print result[:-1] result :-1 -1 for g in g_list:
        list, count = insertionsort(list, length, g, count)

     g g_list list, count = insertionsort(list, length, g, count) list insertionsort(list, length, g, count) insertionsort list length g count count return list, count return list, count list count list list length length l = int(input()) l int(input()) int input() input target = [] target [] for i in range(l):
    target.append(int(input())) i range(l) range l target.append(int(input())) target.append target append int(input()) int input() input result, count = shellsort(target, l) result shellsort(target, l) shellsort target l count print(count) print count for r in result:
    print(r) r result print(r) print r count = shellsort(target, l) shellsort(target, l) count def shellsort(list, length):
    count = 0
    g_list = [1]
    g_cell = 4
    while g_cell < length:
        g_list.append(g_cell)
        g_cell = g_cell * 3 + 1

    g_list.reverse()
    print(len(g_list))
    result = ''
    for g in g_list:
        result += str(g) + ' '
    print(result[:-1])

    for g in g_list:
        list, count = insertionsort(list, length, g, count)

    return list, count def shellsort(list, length):
    count = 0
    g_list = [1]
    g_cell = 4
    while g_cell < length:
        g_list.append(g_cell)
        g_cell = g_cell * 3 + 1

    g_list.reverse()
    print(len(g_list))
    result = ''
    for g in g_list:
        result += str(g) + ' '
    print(result[:-1])

    for g in g_list:
        list, count = insertionsort(list, length, g, count)

    return list, count shellsort result, count = shellsort(target, l) shellsort(target, l) result def insertionsort(list, length, g, count):
    for i in range(g, length):
        v = list[i]
        j = i - g
        while j >= 0 and list[j] > v:
            list[j+g] = list[j]
            j = j - g
            count += 1
        list[j+g] = v

    return list, count def insertionsort(list, length, g, count):
    for i in range(g, length):
        v = list[i]
        j = i - g
        while j >= 0 and list[j] > v:
            list[j+g] = list[j]
            j = j - g
            count += 1
        list[j+g] = v

    return list, count insertionsort l = int(input()) int(input()) l target = [] [] target
#シェルソート
#挿入ソートは、飛び飛びで値を整列すつもの
#それの飛ぶ範囲をどんどん狭めていって正解を出す
import math

def insertionsort(list, length, g, count):
    for i in range(g, length):
        v = list[i]
        j = i - g
        while j >= 0 and list[j] > v:
            list[j+g] = list[j]
            j = j - g
            count += 1
        list[j+g] = v

    return list, count

def shellsort(list, length):
    count = 0
    g_list = [1]
    g_cell = 4
    while g_cell < length:
        g_list.append(g_cell)
        g_cell = g_cell * 3 + 1

    g_list.reverse()
    print(len(g_list))
    result = ''
    for g in g_list:
        result += str(g) + ' '
    print(result[:-1])

    for g in g_list:
        list, count = insertionsort(list, length, g, count)

    return list, count

l = int(input())
target = []
for i in range(l):
    target.append(int(input()))

result, count = shellsort(target, l)
print(count)
for r in result:
    print(r)

