def generate_G(n):
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    return G


def insertion_sort(A, n, g):
    global count
    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
            count += 1
        A[j + g] = v


def shell_sort(A, n):
    G = generate_G(n)
    print(len(G))
    print(' '.join(map(str, G)))
    for g in G:
        insertion_sort(A, n, g)


def main():
    global count

    # input
    n = int(input())
    A = [int(input()) for _ in range(n)]

    # sort
    shell_sort(A, n)

    # output
    print(count)
    for a in A:
        print(a)


if __name__ == "__main__":
    count = 0
    main()
 def generate_G(n):
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    return G generate_G h = 1 h 1 G = [] G [] while h <= n:
        G.append(h)
        h = 3 * h + 1
     h <= n h n G.append(h) G.append G append h h = 3 * h + 1 h 3 * h + 1 3 * h 3 h 1 G.reverse() G.reverse G reverse return G G n n def insertion_sort(A, n, g):
    global count
    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
            count += 1
        A[j + g] = v insertion_sort global count 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
            count += 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
            count += 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 count += 1 count 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 = generate_G(n)
    print(len(G))
    print(' '.join(map(str, G)))
    for g in G:
        insertion_sort(A, n, g) shell_sort G = generate_G(n) G generate_G(n) generate_G n print(len(G)) print len(G) len G print(' '.join(map(str, G))) print ' '.join(map(str, G)) ' '.join ' ' join map(str, G) map str G for g in G:
        insertion_sort(A, n, g) g G insertion_sort(A, n, g) insertion_sort A n g A A n n def main():
    global count

    # input
    n = int(input())
    A = [int(input()) for _ in range(n)]

    # sort
    shell_sort(A, n)

    # output
    print(count)
    for a in A:
        print(a) main global count n = int(input()) n int(input()) int input() input int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input A = [int(input()) for _ in range(n)] A [int(input()) for _ in range(n)] shell_sort(A, n) shell_sort A n print(count) print count for a in A:
        print(a) a A print(a) print a if __name__ == "__main__":
    count = 0
    main() __name__ == "__main__" __name__ "__main__" count = 0 count 0 main() main def generate_G(n):
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    return G def generate_G(n):
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    return G generate_G def insertion_sort(A, n, g):
    global count
    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
            count += 1
        A[j + g] = v def insertion_sort(A, n, g):
    global count
    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
            count += 1
        A[j + g] = v insertion_sort def main():
    global count

    # input
    n = int(input())
    A = [int(input()) for _ in range(n)]

    # sort
    shell_sort(A, n)

    # output
    print(count)
    for a in A:
        print(a) def main():
    global count

    # input
    n = int(input())
    A = [int(input()) for _ in range(n)]

    # sort
    shell_sort(A, n)

    # output
    print(count)
    for a in A:
        print(a) main count = 0 0 count def shell_sort(A, n):
    G = generate_G(n)
    print(len(G))
    print(' '.join(map(str, G)))
    for g in G:
        insertion_sort(A, n, g) def shell_sort(A, n):
    G = generate_G(n)
    print(len(G))
    print(' '.join(map(str, G)))
    for g in G:
        insertion_sort(A, n, g) shell_sort
def generate_G(n):
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    return G


def insertion_sort(A, n, g):
    global count
    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
            count += 1
        A[j + g] = v


def shell_sort(A, n):
    G = generate_G(n)
    print(len(G))
    print(' '.join(map(str, G)))
    for g in G:
        insertion_sort(A, n, g)


def main():
    global count

    # input
    n = int(input())
    A = [int(input()) for _ in range(n)]

    # sort
    shell_sort(A, n)

    # output
    print(count)
    for a in A:
        print(a)


if __name__ == "__main__":
    count = 0
    main()

