# -*- coding:utf-8 -*-

import math

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

def shell_sort(num_list, length):
    cnt = 0
    h = 4
    intervals = [1,]
    while length > h:
        intervals.append(h)
        h = 3 * h + 1
    for i in reversed(range(len(intervals))):
        cnt = cnt + insertion_sort(num_list, length, intervals[i])
    print(len(intervals))
    show_list(intervals)
    print(cnt)

def show_list(list):
    i = len(list) - 1;
    while i > 0:
        print(list[i], end=" ")
        i = i - 1
    print(list[i])

input_num = int(input())
input_list = list()
for i in range(input_num):
    input_list.append(int(input()))
shell_sort(input_list, input_num)
for num in input_list:
    print(num) import math math def insertion_sort(num_list, length, interval):
    cnt = 0
    for i in range(interval, length):
        v = num_list[i]
        j = i - interval
        while j >= 0 and num_list[j] > v:
            num_list[j+interval] = num_list[j]
            j = j - interval
            cnt = cnt + 1
        num_list[j+interval] = v
    return cnt insertion_sort cnt = 0 cnt 0 for i in range(interval, length):
        v = num_list[i]
        j = i - interval
        while j >= 0 and num_list[j] > v:
            num_list[j+interval] = num_list[j]
            j = j - interval
            cnt = cnt + 1
        num_list[j+interval] = v
     i range(interval, length) range interval length v = num_list[i] v num_list[i] num_list i j = i - interval j i - interval i interval while j >= 0 and num_list[j] > v:
            num_list[j+interval] = num_list[j]
            j = j - interval
            cnt = cnt + 1
         j >= 0 and num_list[j] > v j >= 0 j 0 num_list[j] > v num_list[j] num_list j v num_list[j+interval] = num_list[j] num_list[j+interval] num_list j+interval j interval num_list[j] num_list j j = j - interval j j - interval j interval cnt = cnt + 1 cnt cnt + 1 cnt 1 num_list[j+interval] = v num_list[j+interval] num_list j+interval j interval v return cnt cnt num_list num_list length length interval interval def shell_sort(num_list, length):
    cnt = 0
    h = 4
    intervals = [1,]
    while length > h:
        intervals.append(h)
        h = 3 * h + 1
    for i in reversed(range(len(intervals))):
        cnt = cnt + insertion_sort(num_list, length, intervals[i])
    print(len(intervals))
    show_list(intervals)
    print(cnt) shell_sort cnt = 0 cnt 0 h = 4 h 4 intervals = [1,] intervals [1,] 1 while length > h:
        intervals.append(h)
        h = 3 * h + 1
     length > h length h intervals.append(h) intervals.append intervals append h h = 3 * h + 1 h 3 * h + 1 3 * h 3 h 1 for i in reversed(range(len(intervals))):
        cnt = cnt + insertion_sort(num_list, length, intervals[i])
     i reversed(range(len(intervals))) reversed range(len(intervals)) range len(intervals) len intervals cnt = cnt + insertion_sort(num_list, length, intervals[i]) cnt cnt + insertion_sort(num_list, length, intervals[i]) cnt insertion_sort(num_list, length, intervals[i]) insertion_sort num_list length intervals[i] intervals i print(len(intervals)) print len(intervals) len intervals show_list(intervals) show_list intervals print(cnt) print cnt num_list num_list length length def show_list(list):
    i = len(list) - 1;
    while i > 0:
        print(list[i], end=" ")
        i = i - 1
    print(list[i]) show_list i = len(list) - 1 i len(list) - 1 len(list) len list 1 while i > 0:
        print(list[i], end=" ")
        i = i - 1
     i > 0 i 0 print(list[i], end=" ") print list[i] list i end=" " end " " i = i - 1 i i - 1 i 1 print(list[i]) print list[i] list i list list input_num = int(input()) input_num int(input()) int input() input input_list = list() input_list list() list for i in range(input_num):
    input_list.append(int(input())) i range(input_num) range input_num input_list.append(int(input())) input_list.append input_list append int(input()) int input() input shell_sort(input_list, input_num) shell_sort input_list input_num for num in input_list:
    print(num) num input_list print(num) print num input_list = list() list() input_list def show_list(list):
    i = len(list) - 1;
    while i > 0:
        print(list[i], end=" ")
        i = i - 1
    print(list[i]) def show_list(list):
    i = len(list) - 1;
    while i > 0:
        print(list[i], end=" ")
        i = i - 1
    print(list[i]) show_list def shell_sort(num_list, length):
    cnt = 0
    h = 4
    intervals = [1,]
    while length > h:
        intervals.append(h)
        h = 3 * h + 1
    for i in reversed(range(len(intervals))):
        cnt = cnt + insertion_sort(num_list, length, intervals[i])
    print(len(intervals))
    show_list(intervals)
    print(cnt) def shell_sort(num_list, length):
    cnt = 0
    h = 4
    intervals = [1,]
    while length > h:
        intervals.append(h)
        h = 3 * h + 1
    for i in reversed(range(len(intervals))):
        cnt = cnt + insertion_sort(num_list, length, intervals[i])
    print(len(intervals))
    show_list(intervals)
    print(cnt) shell_sort def insertion_sort(num_list, length, interval):
    cnt = 0
    for i in range(interval, length):
        v = num_list[i]
        j = i - interval
        while j >= 0 and num_list[j] > v:
            num_list[j+interval] = num_list[j]
            j = j - interval
            cnt = cnt + 1
        num_list[j+interval] = v
    return cnt def insertion_sort(num_list, length, interval):
    cnt = 0
    for i in range(interval, length):
        v = num_list[i]
        j = i - interval
        while j >= 0 and num_list[j] > v:
            num_list[j+interval] = num_list[j]
            j = j - interval
            cnt = cnt + 1
        num_list[j+interval] = v
    return cnt insertion_sort input_num = int(input()) int(input()) input_num
# -*- coding:utf-8 -*-

import math

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

def shell_sort(num_list, length):
    cnt = 0
    h = 4
    intervals = [1,]
    while length > h:
        intervals.append(h)
        h = 3 * h + 1
    for i in reversed(range(len(intervals))):
        cnt = cnt + insertion_sort(num_list, length, intervals[i])
    print(len(intervals))
    show_list(intervals)
    print(cnt)

def show_list(list):
    i = len(list) - 1;
    while i > 0:
        print(list[i], end=" ")
        i = i - 1
    print(list[i])

input_num = int(input())
input_list = list()
for i in range(input_num):
    input_list.append(int(input()))
shell_sort(input_list, input_num)
for num in input_list:
    print(num)