# -*- 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(list(range(len(intervals)))):

        cnt = cnt + insertion_sort(num_list, length, intervals[i])

    print((len(intervals)))

    print((*reversed(intervals)))

    print(cnt)



input_num = int(eval(input()))

input_list = list()

for i in range(input_num):

    input_list.append(int(eval(input())))

shell_sort(input_list, input_num)

for num in input_list:

    print(num)
def insertion_sort(A, g):

    cnt = 0

    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 -= g

            cnt += 1

        A[j+g] = v

    return cnt



def shell_sort(A):

    cnt = 0

    h = 1

    G = []

    while h <= len(A)/2:

        G.append(h)

        h = 3 * h + 1

    if len(G) == 0:

        G.append(1)

    print((len(G)))

    print((*G[::-1]))

    for g_i in G[::-1]:

        cnt += insertion_sort(A, g_i)

    return cnt



if __name__ == '__main__':

    n = int(eval(input()))

    A = []

    for i in range(n):

        A.append(int(eval(input())))



    print((shell_sort(A)))

    for a in A:

        print(a)



# -*- 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(list(range(len(intervals)))):
        cnt = cnt + insertion_sort(num_list, length, intervals[i])
    print((len(intervals)))
    print((*reversed(intervals)))
    print(cnt)


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

def insertion_sort(A, g):
    cnt = 0
    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 -= g
            cnt += 1
        A[j + g] = v
    return cnt


def shell_sort(A):
    cnt = 0
    h = 1
    G = []
    while h <= len(A) / 2:
        G.append(h)
        h = 3 * h + 1
    if len(G) == 0:
        G.append(1)
    print((len(G)))
    print((*G[::-1]))
    for g_i in G[::-1]:
        cnt += insertion_sort(A, g_i)
    return cnt


if __name__ == "__main__":
    n = int(eval(input()))
    A = []
    for i in range(n):
        A.append(int(eval(input())))
    print((shell_sort(A)))
    for a in A:
        print(a)

-# -*- coding:utf-8 -*- -import math - - -def insertion_sort(num_list, length, interval): +def insertion_sort(A, g): -    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 +    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 -= g +            cnt += 1 +        A[j + g] = v -def shell_sort(num_list, length): +def shell_sort(A): -    h = 4 -    intervals = [ -        1, -    ] -    while length > h: -        intervals.append(h) +    h = 1 +    G = [] +    while h <= len(A) / 2: +        G.append(h) -    for i in reversed(list(range(len(intervals)))): -        cnt = cnt + insertion_sort(num_list, length, intervals[i]) -    print((len(intervals))) -    print((*reversed(intervals))) -    print(cnt) +    if len(G) == 0: +        G.append(1) +    print((len(G))) +    print((*G[::-1])) +    for g_i in G[::-1]: +        cnt += insertion_sort(A, g_i) +    return cnt -input_num = int(eval(input())) -input_list = list() -for i in range(input_num): -    input_list.append(int(eval(input()))) -shell_sort(input_list, input_num) -for num in input_list: -    print(num) +if __name__ == "__main__": +    n = int(eval(input())) +    A = [] +    for i in range(n): +        A.append(int(eval(input()))) +    print((shell_sort(A))) +    for a in A: +        print(a)