def insertionSort(A, n, g):
    cnt = 0
    for i in xrange(g, n):
        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):
    # variables
    cnt, m, t = 0, 1, n
    # getting m
    while (t-1)/3 > 0:
        t, m = (t-1)/3, m+1
    print m
    # creating and printing G
    G = [1]
    for i in xrange(1,m):
        G.append(1+G[i-1]*3)
    G = list(reversed(G))
    print " ".join( map(str, G) )
    # sorting
    for i in xrange(0, m):
        cnt += insertionSort(A, n, G[i])
    return cnt

# MAIN
n = input()
A = [input() for i in xrange(n)]
cnt = shellSort(A, n)
print cnt
for i in xrange(n):
    print A[i] def insertionSort(A, n, g):
    cnt = 0
    for i in xrange(g, n):
        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):
        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) xrange 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
            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):
    # variables
    cnt, m, t = 0, 1, n
    # getting m
    while (t-1)/3 > 0:
        t, m = (t-1)/3, m+1
    print m
    # creating and printing G
    G = [1]
    for i in xrange(1,m):
        G.append(1+G[i-1]*3)
    G = list(reversed(G))
    print " ".join( map(str, G) )
    # sorting
    for i in xrange(0, m):
        cnt += insertionSort(A, n, G[i])
    return cnt

# MAIN shellSort cnt, m, t = 0, 1, n cnt 0 m 1 t n while (t-1)/3 > 0:
        t, m = (t-1)/3, m+1
     (t-1)/3 > 0 (t-1)/3 t-1 t 1 3 0 t, m = (t-1)/3, m+1 t (t-1)/3 t-1 t 1 3 m m+1 m 1 print G = [1] G [1] 1 for i in xrange(1,m):
        G.append(1+G[i-1]*3)
     i xrange(1,m) xrange 1 m G.append(1+G[i-1]*3) G.append G append 1+G[i-1]*3 1 G[i-1]*3 G[i-1] G i-1 i 1 3 G = list(reversed(G)) G list(reversed(G)) list reversed(G) reversed G print " ".join( map(str, G) ) " ".join " " join map(str, G) map str G for i in xrange(0, m):
        cnt += insertionSort(A, n, G[i])
     i xrange(0, m) xrange 0 m cnt += insertionSort(A, n, G[i]) cnt insertionSort(A, n, G[i]) insertionSort A n G[i] G i return cnt cnt A A n n n = input() n input() input input() for i in xrange(n) for i in xrange(n) i xrange(n) xrange n for i in xrange(n) input() input A = [input() for i in xrange(n)] A [input() for i in xrange(n)] cnt = shellSort(A, n) cnt shellSort(A, n) shellSort A n print for i in xrange(n):
    print A[i] i xrange(n) xrange n print A[i] A i def shellSort(A, n):
    # variables
    cnt, m, t = 0, 1, n
    # getting m
    while (t-1)/3 > 0:
        t, m = (t-1)/3, m+1
    print m
    # creating and printing G
    G = [1]
    for i in xrange(1,m):
        G.append(1+G[i-1]*3)
    G = list(reversed(G))
    print " ".join( map(str, G) )
    # sorting
    for i in xrange(0, m):
        cnt += insertionSort(A, n, G[i])
    return cnt

# MAIN def shellSort(A, n):
    # variables
    cnt, m, t = 0, 1, n
    # getting m
    while (t-1)/3 > 0:
        t, m = (t-1)/3, m+1
    print m
    # creating and printing G
    G = [1]
    for i in xrange(1,m):
        G.append(1+G[i-1]*3)
    G = list(reversed(G))
    print " ".join( map(str, G) )
    # sorting
    for i in xrange(0, m):
        cnt += insertionSort(A, n, G[i])
    return cnt

# MAIN shellSort cnt = shellSort(A, n) shellSort(A, n) cnt def insertionSort(A, n, g):
    cnt = 0
    for i in xrange(g, n):
        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):
        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 = input() input() n A = [input() for i in xrange(n)] [input() for i in xrange(n)] A
def insertionSort(A, n, g):
    cnt = 0
    for i in xrange(g, n):
        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):
    # variables
    cnt, m, t = 0, 1, n
    # getting m
    while (t-1)/3 > 0:
        t, m = (t-1)/3, m+1
    print m
    # creating and printing G
    G = [1]
    for i in xrange(1,m):
        G.append(1+G[i-1]*3)
    G = list(reversed(G))
    print " ".join( map(str, G) )
    # sorting
    for i in xrange(0, m):
        cnt += insertionSort(A, n, G[i])
    return cnt

# MAIN
n = input()
A = [input() for i in xrange(n)]
cnt = shellSort(A, n)
print cnt
for i in xrange(n):
    print A[i]