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 = j - g
            cnt += 1
        A[j+g] = v
    return cnt

def shellSort(A, n):
    cnt = 0
    nn = n
    G = []
    g = 1
    while g <= n:
        G.insert(0, g)
        g = g*3 + 1
    m = len(G)
    for g in G:
        cnt += insertionSort(A, n, g)
    return cnt, m, G

n = int(input())
A = [int(input()) for i in range(n)]
cnt, m, G = shellSort(A, n)
print(m)
print(" ".join(map(str, G)))
print(cnt)
for a in A:
    print(a)
 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 = 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 = 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 = 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
    nn = n
    G = []
    g = 1
    while g <= n:
        G.insert(0, g)
        g = g*3 + 1
    m = len(G)
    for g in G:
        cnt += insertionSort(A, n, g)
    return cnt, m, G shellSort cnt = 0 cnt 0 nn = n nn n G = [] G [] g = 1 g 1 while g <= n:
        G.insert(0, g)
        g = g*3 + 1
     g <= n g n G.insert(0, g) G.insert G insert 0 g g = g*3 + 1 g g*3 + 1 g*3 g 3 1 m = len(G) m len(G) len G for g in G:
        cnt += insertionSort(A, n, g)
     g G cnt += insertionSort(A, n, g) cnt insertionSort(A, n, g) insertionSort A n g return cnt, m, G return cnt, m, G cnt m G 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)] cnt, m, G = shellSort(A, n) cnt shellSort(A, n) shellSort A n m G print(m) print m print(" ".join(map(str, G))) print " ".join(map(str, G)) " ".join " " join map(str, G) map str G print(cnt) print cnt for a in A:
    print(a) a A print(a) print a m, G = shellSort(A, n) shellSort(A, n) m cnt, m, G = shellSort(A, n) shellSort(A, n) cnt A = [int(input()) for i in range(n)] [int(input()) for i in range(n)] A 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 = 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 = j - g
            cnt += 1
        A[j+g] = v
    return cnt insertionSort n = int(input()) int(input()) n def shellSort(A, n):
    cnt = 0
    nn = n
    G = []
    g = 1
    while g <= n:
        G.insert(0, g)
        g = g*3 + 1
    m = len(G)
    for g in G:
        cnt += insertionSort(A, n, g)
    return cnt, m, G def shellSort(A, n):
    cnt = 0
    nn = n
    G = []
    g = 1
    while g <= n:
        G.insert(0, g)
        g = g*3 + 1
    m = len(G)
    for g in G:
        cnt += insertionSort(A, n, g)
    return cnt, m, G shellSort G = shellSort(A, n) shellSort(A, n) G
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 = j - g
            cnt += 1
        A[j+g] = v
    return cnt

def shellSort(A, n):
    cnt = 0
    nn = n
    G = []
    g = 1
    while g <= n:
        G.insert(0, g)
        g = g*3 + 1
    m = len(G)
    for g in G:
        cnt += insertionSort(A, n, g)
    return cnt, m, G

n = int(input())
A = [int(input()) for i in range(n)]
cnt, m, G = shellSort(A, n)
print(m)
print(" ".join(map(str, G)))
print(cnt)
for a in A:
    print(a)

