def insertion_sort(A, n, g):
    global cnt
    for i in range(g, n):
        val = A[i]
        j = i - g
        while j >= 0 and A[j] > val:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = val


def shell_sort(A, n):
    global cnt
    cnt = 0
    G = []
    h = 1
    while h <= len(A):
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    print(len(G))
    print(' '.join(map(str, G)))
    for i in range(0, len(G)):
        insertion_sort(A, n, G[i])


if __name__ == '__main__':
    n = int(input())
    l = [int(input()) for _ in range(n)]
    shell_sort(l, n)
    print(cnt)
    for i in l:
        print(i)
 def insertion_sort(A, n, g):
    global cnt
    for i in range(g, n):
        val = A[i]
        j = i - g
        while j >= 0 and A[j] > val:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = val insertion_sort global cnt for i in range(g, n):
        val = A[i]
        j = i - g
        while j >= 0 and A[j] > val:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = val i range(g, n) range g n val = A[i] val A[i] A i j = i - g j i - g i g while j >= 0 and A[j] > val:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
         j >= 0 and A[j] > val j >= 0 j 0 A[j] > val A[j] A j val 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] = val A[j + g] A j + g j g val A A n n g g def shell_sort(A, n):
    global cnt
    cnt = 0
    G = []
    h = 1
    while h <= len(A):
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    print(len(G))
    print(' '.join(map(str, G)))
    for i in range(0, len(G)):
        insertion_sort(A, n, G[i]) shell_sort global cnt cnt = 0 cnt 0 G = [] G [] h = 1 h 1 while h <= len(A):
        G.append(h)
        h = 3 * h + 1
     h <= len(A) h len(A) len A 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 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(0, len(G)):
        insertion_sort(A, n, G[i]) i range(0, len(G)) range 0 len(G) len G insertion_sort(A, n, G[i]) insertion_sort A n G[i] G i A A n n if __name__ == '__main__':
    n = int(input())
    l = [int(input()) for _ in range(n)]
    shell_sort(l, n)
    print(cnt)
    for i in l:
        print(i) __name__ == '__main__' __name__ '__main__' 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 l = [int(input()) for _ in range(n)] l [int(input()) for _ in range(n)] shell_sort(l, n) shell_sort l n print(cnt) print cnt for i in l:
        print(i) i l print(i) print i l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l n = int(input()) int(input()) n def insertion_sort(A, n, g):
    global cnt
    for i in range(g, n):
        val = A[i]
        j = i - g
        while j >= 0 and A[j] > val:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = val def insertion_sort(A, n, g):
    global cnt
    for i in range(g, n):
        val = A[i]
        j = i - g
        while j >= 0 and A[j] > val:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = val insertion_sort def shell_sort(A, n):
    global cnt
    cnt = 0
    G = []
    h = 1
    while h <= len(A):
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    print(len(G))
    print(' '.join(map(str, G)))
    for i in range(0, len(G)):
        insertion_sort(A, n, G[i]) def shell_sort(A, n):
    global cnt
    cnt = 0
    G = []
    h = 1
    while h <= len(A):
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    print(len(G))
    print(' '.join(map(str, G)))
    for i in range(0, len(G)):
        insertion_sort(A, n, G[i]) shell_sort
def insertion_sort(A, n, g):
    global cnt
    for i in range(g, n):
        val = A[i]
        j = i - g
        while j >= 0 and A[j] > val:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = val


def shell_sort(A, n):
    global cnt
    cnt = 0
    G = []
    h = 1
    while h <= len(A):
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    print(len(G))
    print(' '.join(map(str, G)))
    for i in range(0, len(G)):
        insertion_sort(A, n, G[i])


if __name__ == '__main__':
    n = int(input())
    l = [int(input()) for _ in range(n)]
    shell_sort(l, n)
    print(cnt)
    for i in l:
        print(i)

