def insertion_sort(A, n, g, 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 = j - g
            count += 1

        A[j+g] = v

    return count

def shell_sort(A, n):
    count = 0
    g = 1
    G = []

    while g <= n:
        G.insert(0, g)
        g = g*3 + 1

    print(len(G))
    print(' '.join(map(str, G)))

    for i in range(len(G)):
        count = insertion_sort(A, n, G[i], count)

    print(count)
    print('\n'.join(map(str, A)))

if __name__ == '__main__':
    n = int(input())
    A = [int(input()) for i in range(n)]

    shell_sort(A, n) def insertion_sort(A, n, g, 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 = j - g
            count += 1

        A[j+g] = v

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

    while g <= n:
        G.insert(0, g)
        g = g*3 + 1

    print(len(G))
    print(' '.join(map(str, G)))

    for i in range(len(G)):
        count = insertion_sort(A, n, G[i], count)

    print(count)
    print('\n'.join(map(str, A))) shell_sort count = 0 count 0 g = 1 g 1 G = [] G [] while g <= n:
        G.insert(0, g)
        g = g*3 + 1

     g <= n g n G.insert(0, g) G.insert G insert 0 g g = g*3 + 1 g g*3 + 1 g*3 g 3 1 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 i in range(len(G)):
        count = insertion_sort(A, n, G[i], count)

     i range(len(G)) range len(G) len G count = insertion_sort(A, n, G[i], count) count insertion_sort(A, n, G[i], count) insertion_sort A n G[i] G i count print(count) print count print('\n'.join(map(str, A))) print '\n'.join(map(str, A)) '\n'.join '\n' join map(str, A) map str A A A n n if __name__ == '__main__':
    n = int(input())
    A = [int(input()) for i in range(n)]

    shell_sort(A, n) __name__ == '__main__' __name__ '__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 A = [int(input()) for i in range(n)] [int(input()) for i in range(n)] A n = int(input()) int(input()) n def insertion_sort(A, n, g, 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 = j - g
            count += 1

        A[j+g] = v

    return count def insertion_sort(A, n, g, 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 = j - g
            count += 1

        A[j+g] = v

    return count insertion_sort def shell_sort(A, n):
    count = 0
    g = 1
    G = []

    while g <= n:
        G.insert(0, g)
        g = g*3 + 1

    print(len(G))
    print(' '.join(map(str, G)))

    for i in range(len(G)):
        count = insertion_sort(A, n, G[i], count)

    print(count)
    print('\n'.join(map(str, A))) def shell_sort(A, n):
    count = 0
    g = 1
    G = []

    while g <= n:
        G.insert(0, g)
        g = g*3 + 1

    print(len(G))
    print(' '.join(map(str, G)))

    for i in range(len(G)):
        count = insertion_sort(A, n, G[i], count)

    print(count)
    print('\n'.join(map(str, A))) shell_sort
def insertion_sort(A, n, g, 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 = j - g
            count += 1

        A[j+g] = v

    return count

def shell_sort(A, n):
    count = 0
    g = 1
    G = []

    while g <= n:
        G.insert(0, g)
        g = g*3 + 1

    print(len(G))
    print(' '.join(map(str, G)))

    for i in range(len(G)):
        count = insertion_sort(A, n, G[i], count)

    print(count)
    print('\n'.join(map(str, A)))

if __name__ == '__main__':
    n = int(input())
    A = [int(input()) for i in range(n)]

    shell_sort(A, n)