import sys

cnt = 0
g = []

def insertion_sort(a, n, g):
    global cnt
    
    for i in range(g, n):
        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(a, n):
    global g

    h = 1
    while True:
        if h > n:
            break

        g.append(h)
        h = h * 3 + 1

    for i in range(len(g)-1, -1, -1):
        insertion_sort(a, n, g[i])
    
def main():
    n = int(sys.stdin.readline().strip())
    a = []

    for i in range(n):
        a.append(int(sys.stdin.readline().strip()))

    shell_sort(a, n)

    print(len(g))

    for i in range(len(g)-1, -1, -1):
        print(g[i], end='')
        if i:
            print(' ', end='')

    print('')
    print(cnt)

    for i in range(n):
        print(a[i])

if __name__ == '__main__':
    main() import sys sys cnt = 0 cnt 0 g = [] g [] def insertion_sort(a, n, g):
    global cnt
    
    for i in range(g, n):
        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 insertion_sort global cnt for i in range(g, n):
        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 i range(g, n) range g n v = a[i] v a[i] a i j = i - g j i - g i g while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j -= g
            cnt += 1

         j >= 0 and a[j] > v j >= 0 j 0 a[j] > v a[j] a j v a[j+g] = a[j] a[j+g] a j+g j g a[j] a j j -= g j g cnt += 1 cnt 1 a[j+g] = v a[j+g] a j+g j g v a a n n g g def shell_sort(a, n):
    global g

    h = 1
    while True:
        if h > n:
            break

        g.append(h)
        h = h * 3 + 1

    for i in range(len(g)-1, -1, -1):
        insertion_sort(a, n, g[i])
     shell_sort global g h = 1 h 1 while True:
        if h > n:
            break

        g.append(h)
        h = h * 3 + 1

     True if h > n:
            break

         h > n h n break g.append(h) g.append g append h h = h * 3 + 1 h h * 3 + 1 h * 3 h 3 1 for i in range(len(g)-1, -1, -1):
        insertion_sort(a, n, g[i])
     i range(len(g)-1, -1, -1) range len(g)-1 len(g) len g 1 -1 -1 insertion_sort(a, n, g[i]) insertion_sort a n g[i] g i a a n n def main():
    n = int(sys.stdin.readline().strip())
    a = []

    for i in range(n):
        a.append(int(sys.stdin.readline().strip()))

    shell_sort(a, n)

    print(len(g))

    for i in range(len(g)-1, -1, -1):
        print(g[i], end='')
        if i:
            print(' ', end='')

    print('')
    print(cnt)

    for i in range(n):
        print(a[i]) main n = int(sys.stdin.readline().strip()) n int(sys.stdin.readline().strip()) int sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip a = [] a [] for i in range(n):
        a.append(int(sys.stdin.readline().strip()))

     i range(n) range n a.append(int(sys.stdin.readline().strip())) a.append a append int(sys.stdin.readline().strip()) int sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip shell_sort(a, n) shell_sort a n print(len(g)) print len(g) len g for i in range(len(g)-1, -1, -1):
        print(g[i], end='')
        if i:
            print(' ', end='')

     i range(len(g)-1, -1, -1) range len(g)-1 len(g) len g 1 -1 -1 print(g[i], end='') print g[i] g i end='' end '' if i:
            print(' ', end='')

     i print(' ', end='') print ' ' end='' end '' print('') print '' print(cnt) print cnt for i in range(n):
        print(a[i]) i range(n) range n print(a[i]) print a[i] a i if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def shell_sort(a, n):
    global g

    h = 1
    while True:
        if h > n:
            break

        g.append(h)
        h = h * 3 + 1

    for i in range(len(g)-1, -1, -1):
        insertion_sort(a, n, g[i])
     def shell_sort(a, n):
    global g

    h = 1
    while True:
        if h > n:
            break

        g.append(h)
        h = h * 3 + 1

    for i in range(len(g)-1, -1, -1):
        insertion_sort(a, n, g[i])
     shell_sort def main():
    n = int(sys.stdin.readline().strip())
    a = []

    for i in range(n):
        a.append(int(sys.stdin.readline().strip()))

    shell_sort(a, n)

    print(len(g))

    for i in range(len(g)-1, -1, -1):
        print(g[i], end='')
        if i:
            print(' ', end='')

    print('')
    print(cnt)

    for i in range(n):
        print(a[i]) def main():
    n = int(sys.stdin.readline().strip())
    a = []

    for i in range(n):
        a.append(int(sys.stdin.readline().strip()))

    shell_sort(a, n)

    print(len(g))

    for i in range(len(g)-1, -1, -1):
        print(g[i], end='')
        if i:
            print(' ', end='')

    print('')
    print(cnt)

    for i in range(n):
        print(a[i]) main g = [] [] g def insertion_sort(a, n, g):
    global cnt
    
    for i in range(g, n):
        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 insertion_sort(a, n, g):
    global cnt
    
    for i in range(g, n):
        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 insertion_sort cnt = 0 0 cnt
import sys

cnt = 0
g = []

def insertion_sort(a, n, g):
    global cnt
    
    for i in range(g, n):
        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(a, n):
    global g

    h = 1
    while True:
        if h > n:
            break

        g.append(h)
        h = h * 3 + 1

    for i in range(len(g)-1, -1, -1):
        insertion_sort(a, n, g[i])
    
def main():
    n = int(sys.stdin.readline().strip())
    a = []

    for i in range(n):
        a.append(int(sys.stdin.readline().strip()))

    shell_sort(a, n)

    print(len(g))

    for i in range(len(g)-1, -1, -1):
        print(g[i], end='')
        if i:
            print(' ', end='')

    print('')
    print(cnt)

    for i in range(n):
        print(a[i])

if __name__ == '__main__':
    main()