import math


def insertion_sort(alist, step):
    size = len(alist)
    count = 0

    for i in range(step, size): 
        v = alist[i]
        j = i - step
        while j >= 0 and alist[j] > v:
            alist[j+step] = alist[j]
            j -= step
            count += 1
        alist[j+step] = v

    return (count, alist)


def shell_sort(alist, steps):   
    total_count = 0
    sorted_list = alist

    for step in steps:
        (count, sorted_list) = insertion_sort(sorted_list, step)
        total_count += count

    return (total_count, sorted_list)


def run():
    n = int(input())
    nums = []
    for i in range(n):
        nums.append(int(input()))

    steps = create_steps(n)
    (cnt, nums) = shell_sort(nums, steps)

    print(len(steps))
    print(" ".join([str(s) for s in steps]))
    print(cnt)
    for n in nums:
        print(n)


def create_steps(n):
    steps = []
    k = 1
    while True:
        steps = [k] + steps
        k =  2 * k + int(math.sqrt(k)) + 1
        if k >= n:
            break

    return steps


if __name__ == '__main__':
    run()
 import math math def insertion_sort(alist, step):
    size = len(alist)
    count = 0

    for i in range(step, size): 
        v = alist[i]
        j = i - step
        while j >= 0 and alist[j] > v:
            alist[j+step] = alist[j]
            j -= step
            count += 1
        alist[j+step] = v

    return (count, alist) insertion_sort size = len(alist) size len(alist) len alist count = 0 count 0 for i in range(step, size): 
        v = alist[i]
        j = i - step
        while j >= 0 and alist[j] > v:
            alist[j+step] = alist[j]
            j -= step
            count += 1
        alist[j+step] = v

     i range(step, size) range step size v = alist[i] v alist[i] alist i j = i - step j i - step i step while j >= 0 and alist[j] > v:
            alist[j+step] = alist[j]
            j -= step
            count += 1
         j >= 0 and alist[j] > v j >= 0 j 0 alist[j] > v alist[j] alist j v alist[j+step] = alist[j] alist[j+step] alist j+step j step alist[j] alist j j -= step j step count += 1 count 1 alist[j+step] = v alist[j+step] alist j+step j step v return (count, alist) (count, alist) count alist alist alist step step def shell_sort(alist, steps):   
    total_count = 0
    sorted_list = alist

    for step in steps:
        (count, sorted_list) = insertion_sort(sorted_list, step)
        total_count += count

    return (total_count, sorted_list) shell_sort total_count = 0 total_count 0 sorted_list = alist sorted_list alist for step in steps:
        (count, sorted_list) = insertion_sort(sorted_list, step)
        total_count += count

     step steps (count, sorted_list) = insertion_sort(sorted_list, step) (count, sorted_list) count sorted_list insertion_sort(sorted_list, step) insertion_sort sorted_list step total_count += count total_count count return (total_count, sorted_list) (total_count, sorted_list) total_count sorted_list alist alist steps steps def run():
    n = int(input())
    nums = []
    for i in range(n):
        nums.append(int(input()))

    steps = create_steps(n)
    (cnt, nums) = shell_sort(nums, steps)

    print(len(steps))
    print(" ".join([str(s) for s in steps]))
    print(cnt)
    for n in nums:
        print(n) run n = int(input()) n int(input()) int input() input nums = [] nums [] for i in range(n):
        nums.append(int(input()))

     i range(n) range n nums.append(int(input())) nums.append nums append int(input()) int input() input steps = create_steps(n) steps create_steps(n) create_steps n (cnt, nums) = shell_sort(nums, steps) (cnt, nums) cnt nums shell_sort(nums, steps) shell_sort nums steps print(len(steps)) print len(steps) len steps str(s) for s in steps for s in steps s steps for s in steps str(s) str s print(" ".join([str(s) for s in steps])) print " ".join([str(s) for s in steps]) " ".join " " join [str(s) for s in steps] print(cnt) print cnt for n in nums:
        print(n) n nums print(n) print n def create_steps(n):
    steps = []
    k = 1
    while True:
        steps = [k] + steps
        k =  2 * k + int(math.sqrt(k)) + 1
        if k >= n:
            break

    return steps create_steps steps = [] steps [] k = 1 k 1 while True:
        steps = [k] + steps
        k =  2 * k + int(math.sqrt(k)) + 1
        if k >= n:
            break

     True steps = [k] + steps steps [k] + steps [k] k steps k =  2 * k + int(math.sqrt(k)) + 1 k 2 * k + int(math.sqrt(k)) + 1 2 * k + int(math.sqrt(k)) 2 * k 2 k int(math.sqrt(k)) int math.sqrt(k) math.sqrt math sqrt k 1 if k >= n:
            break

     k >= n k n break return steps steps n n if __name__ == '__main__':
    run() __name__ == '__main__' __name__ '__main__' run() run def run():
    n = int(input())
    nums = []
    for i in range(n):
        nums.append(int(input()))

    steps = create_steps(n)
    (cnt, nums) = shell_sort(nums, steps)

    print(len(steps))
    print(" ".join([str(s) for s in steps]))
    print(cnt)
    for n in nums:
        print(n) def run():
    n = int(input())
    nums = []
    for i in range(n):
        nums.append(int(input()))

    steps = create_steps(n)
    (cnt, nums) = shell_sort(nums, steps)

    print(len(steps))
    print(" ".join([str(s) for s in steps]))
    print(cnt)
    for n in nums:
        print(n) run def insertion_sort(alist, step):
    size = len(alist)
    count = 0

    for i in range(step, size): 
        v = alist[i]
        j = i - step
        while j >= 0 and alist[j] > v:
            alist[j+step] = alist[j]
            j -= step
            count += 1
        alist[j+step] = v

    return (count, alist) def insertion_sort(alist, step):
    size = len(alist)
    count = 0

    for i in range(step, size): 
        v = alist[i]
        j = i - step
        while j >= 0 and alist[j] > v:
            alist[j+step] = alist[j]
            j -= step
            count += 1
        alist[j+step] = v

    return (count, alist) insertion_sort def shell_sort(alist, steps):   
    total_count = 0
    sorted_list = alist

    for step in steps:
        (count, sorted_list) = insertion_sort(sorted_list, step)
        total_count += count

    return (total_count, sorted_list) def shell_sort(alist, steps):   
    total_count = 0
    sorted_list = alist

    for step in steps:
        (count, sorted_list) = insertion_sort(sorted_list, step)
        total_count += count

    return (total_count, sorted_list) shell_sort def create_steps(n):
    steps = []
    k = 1
    while True:
        steps = [k] + steps
        k =  2 * k + int(math.sqrt(k)) + 1
        if k >= n:
            break

    return steps def create_steps(n):
    steps = []
    k = 1
    while True:
        steps = [k] + steps
        k =  2 * k + int(math.sqrt(k)) + 1
        if k >= n:
            break

    return steps create_steps
import math


def insertion_sort(alist, step):
    size = len(alist)
    count = 0

    for i in range(step, size): 
        v = alist[i]
        j = i - step
        while j >= 0 and alist[j] > v:
            alist[j+step] = alist[j]
            j -= step
            count += 1
        alist[j+step] = v

    return (count, alist)


def shell_sort(alist, steps):   
    total_count = 0
    sorted_list = alist

    for step in steps:
        (count, sorted_list) = insertion_sort(sorted_list, step)
        total_count += count

    return (total_count, sorted_list)


def run():
    n = int(input())
    nums = []
    for i in range(n):
        nums.append(int(input()))

    steps = create_steps(n)
    (cnt, nums) = shell_sort(nums, steps)

    print(len(steps))
    print(" ".join([str(s) for s in steps]))
    print(cnt)
    for n in nums:
        print(n)


def create_steps(n):
    steps = []
    k = 1
    while True:
        steps = [k] + steps
        k =  2 * k + int(math.sqrt(k)) + 1
        if k >= n:
            break

    return steps


if __name__ == '__main__':
    run()

