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

def shellSort(A, n):
    global cnt
    cnt = 0
    G =[]
    g = 0
    for h in range(100):
        g = 3*g + 1
        if g <= n:
            G.insert(0,g)
        m = len(G)

    for  i in range(m):
        insertionSort(A, n, G[i])
    print(m)
    print(*G)
    print(cnt)
    print(*A,sep="\n")

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

shellSort(A, n) def insertionSort(A, n, g):
    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
            global cnt
            cnt += 1
        A[j+g] = v insertionSort 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
            global cnt
            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 = j - g
            global cnt
            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 = j - g j j - g j g global cnt 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
    cnt = 0
    G =[]
    g = 0
    for h in range(100):
        g = 3*g + 1
        if g <= n:
            G.insert(0,g)
        m = len(G)

    for  i in range(m):
        insertionSort(A, n, G[i])
    print(m)
    print(*G)
    print(cnt)
    print(*A,sep="\n") shellSort global cnt cnt = 0 cnt 0 G =[] G [] g = 0 g 0 for h in range(100):
        g = 3*g + 1
        if g <= n:
            G.insert(0,g)
        m = len(G)

     h range(100) range 100 g = 3*g + 1 g 3*g + 1 3*g 3 g 1 if g <= n:
            G.insert(0,g)
         g <= n g n G.insert(0,g) G.insert G insert 0 g m = len(G) m len(G) len G for  i in range(m):
        insertionSort(A, n, G[i])
     i range(m) range m 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 print(*A,sep="\n") print *A A sep="\n" sep "\n" A A n n 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 A = [int(input()) for i in range(n)] [int(input()) for i in range(n)] A n = int(input()) int(input()) n def insertionSort(A, n, g):
    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
            global cnt
            cnt += 1
        A[j+g] = v def insertionSort(A, n, g):
    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
            global cnt
            cnt += 1
        A[j+g] = v insertionSort def shellSort(A, n):
    global cnt
    cnt = 0
    G =[]
    g = 0
    for h in range(100):
        g = 3*g + 1
        if g <= n:
            G.insert(0,g)
        m = len(G)

    for  i in range(m):
        insertionSort(A, n, G[i])
    print(m)
    print(*G)
    print(cnt)
    print(*A,sep="\n") def shellSort(A, n):
    global cnt
    cnt = 0
    G =[]
    g = 0
    for h in range(100):
        g = 3*g + 1
        if g <= n:
            G.insert(0,g)
        m = len(G)

    for  i in range(m):
        insertionSort(A, n, G[i])
    print(m)
    print(*G)
    print(cnt)
    print(*A,sep="\n") shellSort
def insertionSort(A, n, g):
    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
            global cnt
            cnt += 1
        A[j+g] = v

def shellSort(A, n):
    global cnt
    cnt = 0
    G =[]
    g = 0
    for h in range(100):
        g = 3*g + 1
        if g <= n:
            G.insert(0,g)
        m = len(G)

    for  i in range(m):
        insertionSort(A, n, G[i])
    print(m)
    print(*G)
    print(cnt)
    print(*A,sep="\n")

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

shellSort(A, n)
