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

def shell_sort(array, ga):
    cnt = 0
    for g in ga:
        cnt += insertion_sort(array, g)
    return cnt

def print_array(array):
     print(str(array)[1:-1].replace(', ', ' '))


def main():
    N = int(input())
    array = [int(input()) for i in range(N)]
    # ga = [i for i in reversed(range(N)) if i % 3 == 1]
    ga = []
    v = 1
    while v <= N:
        ga.append(v)
        v = v * 3 + 1
    ga.reverse()
    cnt = shell_sort(array, ga)

    print(len(ga))
    print_array(ga)
    print(cnt)
    for v in array:
        print(v)

if __name__ == '__main__':
    main() def insertion_sort(array, g):
    cnt = 0
    for i in range(g,len(array)):
        key = array[i]
        j = i - g
        while j >= 0 and array[j] > key:
            array[j+g] = array[j]
            j -= g
            cnt += 1
        array[j+g] = key
    return cnt insertion_sort cnt = 0 cnt 0 for i in range(g,len(array)):
        key = array[i]
        j = i - g
        while j >= 0 and array[j] > key:
            array[j+g] = array[j]
            j -= g
            cnt += 1
        array[j+g] = key
     i range(g,len(array)) range g len(array) len array key = array[i] key array[i] array i j = i - g j i - g i g while j >= 0 and array[j] > key:
            array[j+g] = array[j]
            j -= g
            cnt += 1
         j >= 0 and array[j] > key j >= 0 j 0 array[j] > key array[j] array j key array[j+g] = array[j] array[j+g] array j+g j g array[j] array j j -= g j g cnt += 1 cnt 1 array[j+g] = key array[j+g] array j+g j g key return cnt cnt array array g g def shell_sort(array, ga):
    cnt = 0
    for g in ga:
        cnt += insertion_sort(array, g)
    return cnt shell_sort cnt = 0 cnt 0 for g in ga:
        cnt += insertion_sort(array, g)
     g ga cnt += insertion_sort(array, g) cnt insertion_sort(array, g) insertion_sort array g return cnt cnt array array ga ga def print_array(array):
     print(str(array)[1:-1].replace(', ', ' ')) print_array print(str(array)[1:-1].replace(', ', ' ')) print str(array)[1:-1].replace(', ', ' ') [1:-1].replace [1:-1] (array) str array 1:-1 1 -1 replace ', ' ' ' array array def main():
    N = int(input())
    array = [int(input()) for i in range(N)]
    # ga = [i for i in reversed(range(N)) if i % 3 == 1]
    ga = []
    v = 1
    while v <= N:
        ga.append(v)
        v = v * 3 + 1
    ga.reverse()
    cnt = shell_sort(array, ga)

    print(len(ga))
    print_array(ga)
    print(cnt)
    for v in array:
        print(v) main N = int(input()) N int(input()) int input() input int(input()) for i in range(N) for i in range(N) i range(N) range N for i in range(N) int(input()) int input() input array = [int(input()) for i in range(N)] array [int(input()) for i in range(N)] ga = [] ga [] v = 1 v 1 while v <= N:
        ga.append(v)
        v = v * 3 + 1
     v <= N v N ga.append(v) ga.append ga append v v = v * 3 + 1 v v * 3 + 1 v * 3 v 3 1 ga.reverse() ga.reverse ga reverse cnt = shell_sort(array, ga) cnt shell_sort(array, ga) shell_sort array ga print(len(ga)) print len(ga) len ga print_array(ga) print_array ga print(cnt) print cnt for v in array:
        print(v) v array print(v) print v if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def insertion_sort(array, g):
    cnt = 0
    for i in range(g,len(array)):
        key = array[i]
        j = i - g
        while j >= 0 and array[j] > key:
            array[j+g] = array[j]
            j -= g
            cnt += 1
        array[j+g] = key
    return cnt def insertion_sort(array, g):
    cnt = 0
    for i in range(g,len(array)):
        key = array[i]
        j = i - g
        while j >= 0 and array[j] > key:
            array[j+g] = array[j]
            j -= g
            cnt += 1
        array[j+g] = key
    return cnt insertion_sort def shell_sort(array, ga):
    cnt = 0
    for g in ga:
        cnt += insertion_sort(array, g)
    return cnt def shell_sort(array, ga):
    cnt = 0
    for g in ga:
        cnt += insertion_sort(array, g)
    return cnt shell_sort def main():
    N = int(input())
    array = [int(input()) for i in range(N)]
    # ga = [i for i in reversed(range(N)) if i % 3 == 1]
    ga = []
    v = 1
    while v <= N:
        ga.append(v)
        v = v * 3 + 1
    ga.reverse()
    cnt = shell_sort(array, ga)

    print(len(ga))
    print_array(ga)
    print(cnt)
    for v in array:
        print(v) def main():
    N = int(input())
    array = [int(input()) for i in range(N)]
    # ga = [i for i in reversed(range(N)) if i % 3 == 1]
    ga = []
    v = 1
    while v <= N:
        ga.append(v)
        v = v * 3 + 1
    ga.reverse()
    cnt = shell_sort(array, ga)

    print(len(ga))
    print_array(ga)
    print(cnt)
    for v in array:
        print(v) main def print_array(array):
     print(str(array)[1:-1].replace(', ', ' ')) def print_array(array):
     print(str(array)[1:-1].replace(', ', ' ')) print_array
def insertion_sort(array, g):
    cnt = 0
    for i in range(g,len(array)):
        key = array[i]
        j = i - g
        while j >= 0 and array[j] > key:
            array[j+g] = array[j]
            j -= g
            cnt += 1
        array[j+g] = key
    return cnt

def shell_sort(array, ga):
    cnt = 0
    for g in ga:
        cnt += insertion_sort(array, g)
    return cnt

def print_array(array):
     print(str(array)[1:-1].replace(', ', ' '))


def main():
    N = int(input())
    array = [int(input()) for i in range(N)]
    # ga = [i for i in reversed(range(N)) if i % 3 == 1]
    ga = []
    v = 1
    while v <= N:
        ga.append(v)
        v = v * 3 + 1
    ga.reverse()
    cnt = shell_sort(array, ga)

    print(len(ga))
    print_array(ga)
    print(cnt)
    for v in array:
        print(v)

if __name__ == '__main__':
    main()