def insertionSort(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 shellSort(A, n):
    global cnt
    G = []
    m = 1
    G.append(1)
    while 3*G[-1]+1 <= n:
        g = G[-1]
        G.append(g*3+1)
        m += 1
    G = sorted(G, reverse=True)
    for i in range(m):
        g = G[i]
        insertionSort(A, n, G[i])

    print(m)
    print(*G)
    print(cnt)
    for a in A:
        print(a)


def main():
    global cnt
    cnt = 0
    N = int(input())
    A = [int(input()) for i in range(N)]
    shellSort(A, N)

 
if __name__ == '__main__':
    main()
 def insertionSort(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 insertionSort 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 shellSort(A, n):
    global cnt
    G = []
    m = 1
    G.append(1)
    while 3*G[-1]+1 <= n:
        g = G[-1]
        G.append(g*3+1)
        m += 1
    G = sorted(G, reverse=True)
    for i in range(m):
        g = G[i]
        insertionSort(A, n, G[i])

    print(m)
    print(*G)
    print(cnt)
    for a in A:
        print(a) shellSort global cnt G = [] G [] m = 1 m 1 G.append(1) G.append G append 1 while 3*G[-1]+1 <= n:
        g = G[-1]
        G.append(g*3+1)
        m += 1
     3*G[-1]+1 <= n 3*G[-1]+1 3*G[-1] 3 G[-1] G -1 1 n g = G[-1] g G[-1] G -1 G.append(g*3+1) G.append G append g*3+1 g*3 g 3 1 m += 1 m 1 G = sorted(G, reverse=True) G sorted(G, reverse=True) sorted G reverse=True reverse True for i in range(m):
        g = G[i]
        insertionSort(A, n, G[i])

     i range(m) range m g = G[i] g G[i] G i insertionSort(A, n, G[i]) insertionSort A n G[i] G i print(m) print m print(*G) print *G G print(cnt) print cnt for a in A:
        print(a) a A print(a) print a A A n n def main():
    global cnt
    cnt = 0
    N = int(input())
    A = [int(input()) for i in range(N)]
    shellSort(A, N)

  main global cnt cnt = 0 cnt 0 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)] shellSort(A, N) shellSort A N if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def shellSort(A, n):
    global cnt
    G = []
    m = 1
    G.append(1)
    while 3*G[-1]+1 <= n:
        g = G[-1]
        G.append(g*3+1)
        m += 1
    G = sorted(G, reverse=True)
    for i in range(m):
        g = G[i]
        insertionSort(A, n, G[i])

    print(m)
    print(*G)
    print(cnt)
    for a in A:
        print(a) def shellSort(A, n):
    global cnt
    G = []
    m = 1
    G.append(1)
    while 3*G[-1]+1 <= n:
        g = G[-1]
        G.append(g*3+1)
        m += 1
    G = sorted(G, reverse=True)
    for i in range(m):
        g = G[i]
        insertionSort(A, n, G[i])

    print(m)
    print(*G)
    print(cnt)
    for a in A:
        print(a) shellSort def main():
    global cnt
    cnt = 0
    N = int(input())
    A = [int(input()) for i in range(N)]
    shellSort(A, N)

  def main():
    global cnt
    cnt = 0
    N = int(input())
    A = [int(input()) for i in range(N)]
    shellSort(A, N)

  main def insertionSort(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 insertionSort(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 insertionSort
def insertionSort(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 shellSort(A, n):
    global cnt
    G = []
    m = 1
    G.append(1)
    while 3*G[-1]+1 <= n:
        g = G[-1]
        G.append(g*3+1)
        m += 1
    G = sorted(G, reverse=True)
    for i in range(m):
        g = G[i]
        insertionSort(A, n, G[i])

    print(m)
    print(*G)
    print(cnt)
    for a in A:
        print(a)


def main():
    global cnt
    cnt = 0
    N = int(input())
    A = [int(input()) for i in range(N)]
    shellSort(A, N)

 
if __name__ == '__main__':
    main()

