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

def insertionSort(A,n,g):
    cnt = 0
    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

    return cnt

def shellSort(A,n):
    cnt = 0
    m = int((n-1)/3)
    G = [1]
    for i in range(1,n):
        gn = G[i-1]+3**i
        if gn > n:
            break
        G.append(gn)
    m = len(G)
    for i in range(m):
        j = (m-1) - i
        cnt += insertionSort(A,n,G[j])

    return m, G, cnt

m, G, cnt = shellSort(A,n)

print m

for i in range(1,m):
    j = m - i
    print G[j],
print G[0]

print cnt

for item in A:
    print item n = input() n input() input input() for i in range(n) for i in range(n) i range(n) range n for i in range(n) input() input A = [input() for i in range(n)] A [input() for i in range(n)] def insertionSort(A,n,g):
    cnt = 0
    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

    return cnt insertionSort cnt = 0 cnt 0 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 return cnt cnt A A n n g g def shellSort(A,n):
    cnt = 0
    m = int((n-1)/3)
    G = [1]
    for i in range(1,n):
        gn = G[i-1]+3**i
        if gn > n:
            break
        G.append(gn)
    m = len(G)
    for i in range(m):
        j = (m-1) - i
        cnt += insertionSort(A,n,G[j])

    return m, G, cnt shellSort cnt = 0 cnt 0 m = int((n-1)/3) m int((n-1)/3) int (n-1)/3 n-1 n 1 3 G = [1] G [1] 1 for i in range(1,n):
        gn = G[i-1]+3**i
        if gn > n:
            break
        G.append(gn)
     i range(1,n) range 1 n gn = G[i-1]+3**i gn G[i-1]+3**i G[i-1] G i-1 i 1 3**i 3 i if gn > n:
            break
         gn > n gn n break G.append(gn) G.append G append gn m = len(G) m len(G) len G for i in range(m):
        j = (m-1) - i
        cnt += insertionSort(A,n,G[j])

     i range(m) range m j = (m-1) - i j (m-1) - i m-1 m 1 i cnt += insertionSort(A,n,G[j]) cnt insertionSort(A,n,G[j]) insertionSort A n G[j] G j return m, G, cnt return m, G, cnt m G cnt A A n n m, G, cnt = shellSort(A,n) m shellSort(A,n) shellSort A n G cnt print for i in range(1,m):
    j = m - i
    print G[j], i range(1,m) range 1 m j = m - i j m - i m i print G[j] G j print G[0] G 0 print for item in A:
    print item item A print n = input() input() n G, cnt = shellSort(A,n) shellSort(A,n) G m, G, cnt = shellSort(A,n) shellSort(A,n) m j = m - i m - i j def insertionSort(A,n,g):
    cnt = 0
    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

    return cnt def insertionSort(A,n,g):
    cnt = 0
    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

    return cnt insertionSort A = [input() for i in range(n)] [input() for i in range(n)] A cnt = shellSort(A,n) shellSort(A,n) cnt def shellSort(A,n):
    cnt = 0
    m = int((n-1)/3)
    G = [1]
    for i in range(1,n):
        gn = G[i-1]+3**i
        if gn > n:
            break
        G.append(gn)
    m = len(G)
    for i in range(m):
        j = (m-1) - i
        cnt += insertionSort(A,n,G[j])

    return m, G, cnt def shellSort(A,n):
    cnt = 0
    m = int((n-1)/3)
    G = [1]
    for i in range(1,n):
        gn = G[i-1]+3**i
        if gn > n:
            break
        G.append(gn)
    m = len(G)
    for i in range(m):
        j = (m-1) - i
        cnt += insertionSort(A,n,G[j])

    return m, G, cnt shellSort
n = input()
A = [input() for i in range(n)]

def insertionSort(A,n,g):
    cnt = 0
    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

    return cnt

def shellSort(A,n):
    cnt = 0
    m = int((n-1)/3)
    G = [1]
    for i in range(1,n):
        gn = G[i-1]+3**i
        if gn > n:
            break
        G.append(gn)
    m = len(G)
    for i in range(m):
        j = (m-1) - i
        cnt += insertionSort(A,n,G[j])

    return m, G, cnt

m, G, cnt = shellSort(A,n)

print m

for i in range(1,m):
    j = m - i
    print G[j],
print G[0]

print cnt

for item in A:
    print item