cnt = 0


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 = j-g
            cnt += 1
        a[j+g] = v


def shell_sort(a, n):
    g = [1]
    for i in range(100):
        if g[-1]*3+1 < n:
            g.append(g[-1]*3+1)
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str, g)))
    for i in range(m):
        insertion_sort(a, n, g[i])


def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))
    shell_sort(a, n)
    print(cnt)
    for i in a:
        print(i)


if __name__ == "__main__":
    main()
 cnt = 0 cnt 0 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 = 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 = 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 = 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 = j-g 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):
    g = [1]
    for i in range(100):
        if g[-1]*3+1 < n:
            g.append(g[-1]*3+1)
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str, g)))
    for i in range(m):
        insertion_sort(a, n, g[i]) shell_sort g = [1] g [1] 1 for i in range(100):
        if g[-1]*3+1 < n:
            g.append(g[-1]*3+1)
     i range(100) range 100 if g[-1]*3+1 < n:
            g.append(g[-1]*3+1)
     g[-1]*3+1 < n g[-1]*3+1 g[-1]*3 g[-1] g -1 3 1 n g.append(g[-1]*3+1) g.append g append g[-1]*3+1 g[-1]*3 g[-1] g -1 3 1 g.reverse() g.reverse g reverse m = len(g) m len(g) len g print(m) print m print(' '.join(map(str, g))) print ' '.join(map(str, g)) ' '.join ' ' join map(str, g) map str g for i in range(m):
        insertion_sort(a, n, g[i]) i range(m) range m insertion_sort(a, n, g[i]) insertion_sort a n g[i] g i a a n n def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))
    shell_sort(a, n)
    print(cnt)
    for i in a:
        print(i) main n = int(input()) n int(input()) int input() input a = [] a [] for i in range(n):
        a.append(int(input()))
     i range(n) range n a.append(int(input())) a.append a append int(input()) int input() input shell_sort(a, n) shell_sort a n print(cnt) print cnt for i in a:
        print(i) i a print(i) print i if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def shell_sort(a, n):
    g = [1]
    for i in range(100):
        if g[-1]*3+1 < n:
            g.append(g[-1]*3+1)
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str, g)))
    for i in range(m):
        insertion_sort(a, n, g[i]) def shell_sort(a, n):
    g = [1]
    for i in range(100):
        if g[-1]*3+1 < n:
            g.append(g[-1]*3+1)
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str, g)))
    for i in range(m):
        insertion_sort(a, n, g[i]) shell_sort 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 = 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 = j-g
            cnt += 1
        a[j+g] = v insertion_sort def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))
    shell_sort(a, n)
    print(cnt)
    for i in a:
        print(i) def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))
    shell_sort(a, n)
    print(cnt)
    for i in a:
        print(i) main cnt = 0 0 cnt
cnt = 0


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 = j-g
            cnt += 1
        a[j+g] = v


def shell_sort(a, n):
    g = [1]
    for i in range(100):
        if g[-1]*3+1 < n:
            g.append(g[-1]*3+1)
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str, g)))
    for i in range(m):
        insertion_sort(a, n, g[i])


def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))
    shell_sort(a, n)
    print(cnt)
    for i in a:
        print(i)


if __name__ == "__main__":
    main()

