def show(A, n):
    for i in range(n):
        print(A[i])


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 cnt
    cnt = 0

    G = []
    g = 1
    while g <= n:
        G.append(g)
        g = 3 * g + 1

    print(len(G))
    for g in reversed(G):
        if g != 1:
            print(g, end=' ')
        else:
            print(g)
        insertion_sort(A, n, g)
    print(cnt)
    show(A, n)


def main():
    n = int(input())
    A = [int(input()) for i in range(n)]

    shell_sort(A, n)


if __name__ == "__main__":
    main()
 def show(A, n):
    for i in range(n):
        print(A[i]) show for i in range(n):
        print(A[i]) i range(n) range n print(A[i]) print A[i] A i A A n n 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 cnt
    cnt = 0

    G = []
    g = 1
    while g <= n:
        G.append(g)
        g = 3 * g + 1

    print(len(G))
    for g in reversed(G):
        if g != 1:
            print(g, end=' ')
        else:
            print(g)
        insertion_sort(A, n, g)
    print(cnt)
    show(A, n) shell_sort global cnt cnt = 0 cnt 0 G = [] G [] g = 1 g 1 while g <= n:
        G.append(g)
        g = 3 * g + 1

     g <= n g n G.append(g) G.append G append g g = 3 * g + 1 g 3 * g + 1 3 * g 3 g 1 print(len(G)) print len(G) len G for g in reversed(G):
        if g != 1:
            print(g, end=' ')
        else:
            print(g)
        insertion_sort(A, n, g)
     g reversed(G) reversed G if g != 1:
            print(g, end=' ')
        else:
            print(g)
         g != 1 g 1 print(g, end=' ') print g end=' ' end ' ' print(g) print g insertion_sort(A, n, g) insertion_sort A n g print(cnt) print cnt show(A, n) show A n A A n n def main():
    n = int(input())
    A = [int(input()) for i in range(n)]

    shell_sort(A, n) 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 A = [int(input()) for i in range(n)] A [int(input()) for i in range(n)] shell_sort(A, n) shell_sort A n if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n = int(input())
    A = [int(input()) for i in range(n)]

    shell_sort(A, n) def main():
    n = int(input())
    A = [int(input()) for i in range(n)]

    shell_sort(A, n) main 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 def show(A, n):
    for i in range(n):
        print(A[i]) def show(A, n):
    for i in range(n):
        print(A[i]) show def shell_sort(A, n):
    global cnt
    cnt = 0

    G = []
    g = 1
    while g <= n:
        G.append(g)
        g = 3 * g + 1

    print(len(G))
    for g in reversed(G):
        if g != 1:
            print(g, end=' ')
        else:
            print(g)
        insertion_sort(A, n, g)
    print(cnt)
    show(A, n) def shell_sort(A, n):
    global cnt
    cnt = 0

    G = []
    g = 1
    while g <= n:
        G.append(g)
        g = 3 * g + 1

    print(len(G))
    for g in reversed(G):
        if g != 1:
            print(g, end=' ')
        else:
            print(g)
        insertion_sort(A, n, g)
    print(cnt)
    show(A, n) shell_sort
def show(A, n):
    for i in range(n):
        print(A[i])


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 cnt
    cnt = 0

    G = []
    g = 1
    while g <= n:
        G.append(g)
        g = 3 * g + 1

    print(len(G))
    for g in reversed(G):
        if g != 1:
            print(g, end=' ')
        else:
            print(g)
        insertion_sort(A, n, g)
    print(cnt)
    show(A, n)


def main():
    n = int(input())
    A = [int(input()) for i in range(n)]

    shell_sort(A, n)


if __name__ == "__main__":
    main()

