def insertion_sort(array, gap):
    n = len(array)
    cnt = 0
    for i in range(gap, n):
        moving = array[i]
        j = i - gap
        while j >= 0 and array[j] > moving:
            array[j + gap] = array[j]
            j -= gap
            cnt += 1
        array[j + gap] = moving
    return array, cnt


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

    cnt = 0
    gaps = []
    i = 1
    gap = 1
    while gap <= n:
        gaps.append(gap)
        i += 1
        gap = (3 ** i - 1) // 2
    gaps = gaps[:100][::-1]

    # shell_sort
    for gap in gaps:
        array, tmp_cnt = insertion_sort(array, gap)
        cnt += tmp_cnt

    print(len(gaps))
    print(" ".join(map(str, gaps)))
    print(cnt)
    for i in array:
        print(i)
    return

main() def insertion_sort(array, gap):
    n = len(array)
    cnt = 0
    for i in range(gap, n):
        moving = array[i]
        j = i - gap
        while j >= 0 and array[j] > moving:
            array[j + gap] = array[j]
            j -= gap
            cnt += 1
        array[j + gap] = moving
    return array, cnt insertion_sort n = len(array) n len(array) len array cnt = 0 cnt 0 for i in range(gap, n):
        moving = array[i]
        j = i - gap
        while j >= 0 and array[j] > moving:
            array[j + gap] = array[j]
            j -= gap
            cnt += 1
        array[j + gap] = moving
     i range(gap, n) range gap n moving = array[i] moving array[i] array i j = i - gap j i - gap i gap while j >= 0 and array[j] > moving:
            array[j + gap] = array[j]
            j -= gap
            cnt += 1
         j >= 0 and array[j] > moving j >= 0 j 0 array[j] > moving array[j] array j moving array[j + gap] = array[j] array[j + gap] array j + gap j gap array[j] array j j -= gap j gap cnt += 1 cnt 1 array[j + gap] = moving array[j + gap] array j + gap j gap moving return array, cnt return array, cnt array cnt array array gap gap def main():
    n = int(input())
    array = []
    for i in range(n):
        array.append(int(input()))

    cnt = 0
    gaps = []
    i = 1
    gap = 1
    while gap <= n:
        gaps.append(gap)
        i += 1
        gap = (3 ** i - 1) // 2
    gaps = gaps[:100][::-1]

    # shell_sort
    for gap in gaps:
        array, tmp_cnt = insertion_sort(array, gap)
        cnt += tmp_cnt

    print(len(gaps))
    print(" ".join(map(str, gaps)))
    print(cnt)
    for i in array:
        print(i)
    return main n = int(input()) n int(input()) int input() input array = [] array [] for i in range(n):
        array.append(int(input()))

     i range(n) range n array.append(int(input())) array.append array append int(input()) int input() input cnt = 0 cnt 0 gaps = [] gaps [] i = 1 i 1 gap = 1 gap 1 while gap <= n:
        gaps.append(gap)
        i += 1
        gap = (3 ** i - 1) // 2
     gap <= n gap n gaps.append(gap) gaps.append gaps append gap i += 1 i 1 gap = (3 ** i - 1) // 2 gap (3 ** i - 1) // 2 3 ** i - 1 3 ** i 3 i 1 2 gaps = gaps[:100][::-1] gaps gaps[:100][::-1] [:100] gaps :100 100 ::-1 -1 for gap in gaps:
        array, tmp_cnt = insertion_sort(array, gap)
        cnt += tmp_cnt

     gap gaps array, tmp_cnt = insertion_sort(array, gap) array insertion_sort(array, gap) insertion_sort array gap tmp_cnt cnt += tmp_cnt cnt tmp_cnt print(len(gaps)) print len(gaps) len gaps print(" ".join(map(str, gaps))) print " ".join(map(str, gaps)) " ".join " " join map(str, gaps) map str gaps print(cnt) print cnt for i in array:
        print(i)
     i array print(i) print i return main() main def insertion_sort(array, gap):
    n = len(array)
    cnt = 0
    for i in range(gap, n):
        moving = array[i]
        j = i - gap
        while j >= 0 and array[j] > moving:
            array[j + gap] = array[j]
            j -= gap
            cnt += 1
        array[j + gap] = moving
    return array, cnt def insertion_sort(array, gap):
    n = len(array)
    cnt = 0
    for i in range(gap, n):
        moving = array[i]
        j = i - gap
        while j >= 0 and array[j] > moving:
            array[j + gap] = array[j]
            j -= gap
            cnt += 1
        array[j + gap] = moving
    return array, cnt insertion_sort def main():
    n = int(input())
    array = []
    for i in range(n):
        array.append(int(input()))

    cnt = 0
    gaps = []
    i = 1
    gap = 1
    while gap <= n:
        gaps.append(gap)
        i += 1
        gap = (3 ** i - 1) // 2
    gaps = gaps[:100][::-1]

    # shell_sort
    for gap in gaps:
        array, tmp_cnt = insertion_sort(array, gap)
        cnt += tmp_cnt

    print(len(gaps))
    print(" ".join(map(str, gaps)))
    print(cnt)
    for i in array:
        print(i)
    return def main():
    n = int(input())
    array = []
    for i in range(n):
        array.append(int(input()))

    cnt = 0
    gaps = []
    i = 1
    gap = 1
    while gap <= n:
        gaps.append(gap)
        i += 1
        gap = (3 ** i - 1) // 2
    gaps = gaps[:100][::-1]

    # shell_sort
    for gap in gaps:
        array, tmp_cnt = insertion_sort(array, gap)
        cnt += tmp_cnt

    print(len(gaps))
    print(" ".join(map(str, gaps)))
    print(cnt)
    for i in array:
        print(i)
    return main
def insertion_sort(array, gap):
    n = len(array)
    cnt = 0
    for i in range(gap, n):
        moving = array[i]
        j = i - gap
        while j >= 0 and array[j] > moving:
            array[j + gap] = array[j]
            j -= gap
            cnt += 1
        array[j + gap] = moving
    return array, cnt


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

    cnt = 0
    gaps = []
    i = 1
    gap = 1
    while gap <= n:
        gaps.append(gap)
        i += 1
        gap = (3 ** i - 1) // 2
    gaps = gaps[:100][::-1]

    # shell_sort
    for gap in gaps:
        array, tmp_cnt = insertion_sort(array, gap)
        cnt += tmp_cnt

    print(len(gaps))
    print(" ".join(map(str, gaps)))
    print(cnt)
    for i in array:
        print(i)
    return

main()
