def insertionSort(A, n, g):
    cnt = 0
    for i in xrange(g, n, 1):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return cnt

def shellSort(A, n):
    cnt = 0
    G = [1]
    i = 0
    while G[i] * 3 + 1 <= n:
        G.append(G[i] * 3 + 1)
        i += 1
    G.reverse()
    m = len(G)
    print m
    print ' '.join(map(str, G))
    for x in G:
        cnt += insertionSort(A, n, x)
    return cnt

N = int(raw_input())
A = [int(raw_input()) for i in xrange(N)]
cnt = shellSort(A, N)
print cnt
for i in A:
    print i def insertionSort(A, n, g):
    cnt = 0
    for i in xrange(g, n, 1):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return cnt insertionSort cnt = 0 cnt 0 for i in xrange(g, n, 1):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
     i xrange(g, n, 1) xrange g n 1 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
            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 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
    G = [1]
    i = 0
    while G[i] * 3 + 1 <= n:
        G.append(G[i] * 3 + 1)
        i += 1
    G.reverse()
    m = len(G)
    print m
    print ' '.join(map(str, G))
    for x in G:
        cnt += insertionSort(A, n, x)
    return cnt shellSort cnt = 0 cnt 0 G = [1] G [1] 1 i = 0 i 0 while G[i] * 3 + 1 <= n:
        G.append(G[i] * 3 + 1)
        i += 1
     G[i] * 3 + 1 <= n G[i] * 3 + 1 G[i] * 3 G[i] G i 3 1 n G.append(G[i] * 3 + 1) G.append G append G[i] * 3 + 1 G[i] * 3 G[i] G i 3 1 i += 1 i 1 G.reverse() G.reverse G reverse m = len(G) m len(G) len G print print ' '.join(map(str, G)) ' '.join ' ' join map(str, G) map str G for x in G:
        cnt += insertionSort(A, n, x)
     x G cnt += insertionSort(A, n, x) cnt insertionSort(A, n, x) insertionSort A n x return cnt cnt A A n n N = int(raw_input()) N int(raw_input()) int raw_input() raw_input int(raw_input()) for i in xrange(N) for i in xrange(N) i xrange(N) xrange N for i in xrange(N) int(raw_input()) int raw_input() raw_input A = [int(raw_input()) for i in xrange(N)] A [int(raw_input()) for i in xrange(N)] cnt = shellSort(A, N) cnt shellSort(A, N) shellSort A N print for i in A:
    print i i A print cnt = shellSort(A, N) shellSort(A, N) cnt def insertionSort(A, n, g):
    cnt = 0
    for i in xrange(g, n, 1):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return cnt def insertionSort(A, n, g):
    cnt = 0
    for i in xrange(g, n, 1):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return cnt insertionSort N = int(raw_input()) int(raw_input()) N def shellSort(A, n):
    cnt = 0
    G = [1]
    i = 0
    while G[i] * 3 + 1 <= n:
        G.append(G[i] * 3 + 1)
        i += 1
    G.reverse()
    m = len(G)
    print m
    print ' '.join(map(str, G))
    for x in G:
        cnt += insertionSort(A, n, x)
    return cnt def shellSort(A, n):
    cnt = 0
    G = [1]
    i = 0
    while G[i] * 3 + 1 <= n:
        G.append(G[i] * 3 + 1)
        i += 1
    G.reverse()
    m = len(G)
    print m
    print ' '.join(map(str, G))
    for x in G:
        cnt += insertionSort(A, n, x)
    return cnt shellSort A = [int(raw_input()) for i in xrange(N)] [int(raw_input()) for i in xrange(N)] A
def insertionSort(A, n, g):
    cnt = 0
    for i in xrange(g, n, 1):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return cnt

def shellSort(A, n):
    cnt = 0
    G = [1]
    i = 0
    while G[i] * 3 + 1 <= n:
        G.append(G[i] * 3 + 1)
        i += 1
    G.reverse()
    m = len(G)
    print m
    print ' '.join(map(str, G))
    for x in G:
        cnt += insertionSort(A, n, x)
    return cnt

N = int(raw_input())
A = [int(raw_input()) for i in xrange(N)]
cnt = shellSort(A, N)
print cnt
for i in A:
    print i