import sys

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):
    G = list()
    h = 1
    while h ==1 or h < n:
        G.append(h)
        h = h * 3 + 1
    G.reverse()
    m = len(G)
    for i in range(m):
        insertionSort(A, n, G[i])
    print(m)
    print(*G)
    global cnt
    print(cnt)
    for item in A:
        print(item)

cnt = 0
n = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(n)]
shellSort(A, n) import sys sys 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):
    G = list()
    h = 1
    while h ==1 or h < n:
        G.append(h)
        h = h * 3 + 1
    G.reverse()
    m = len(G)
    for i in range(m):
        insertionSort(A, n, G[i])
    print(m)
    print(*G)
    global cnt
    print(cnt)
    for item in A:
        print(item) shellSort G = list() G list() list h = 1 h 1 while h ==1 or h < n:
        G.append(h)
        h = h * 3 + 1
     h ==1 or h < n h ==1 h 1 h < n h n G.append(h) G.append G append h h = h * 3 + 1 h h * 3 + 1 h * 3 h 3 1 G.reverse() G.reverse G reverse 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 global cnt print(cnt) print cnt for item in A:
        print(item) item A print(item) print item A A n n cnt = 0 cnt 0 n = int(sys.stdin.readline()) n int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline int(sys.stdin.readline()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline A = [int(sys.stdin.readline()) for _ in range(n)] A [int(sys.stdin.readline()) for _ in range(n)] shellSort(A, 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 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 n = int(sys.stdin.readline()) int(sys.stdin.readline()) n cnt = 0 0 cnt A = [int(sys.stdin.readline()) for _ in range(n)] [int(sys.stdin.readline()) for _ in range(n)] A def shellSort(A, n):
    G = list()
    h = 1
    while h ==1 or h < n:
        G.append(h)
        h = h * 3 + 1
    G.reverse()
    m = len(G)
    for i in range(m):
        insertionSort(A, n, G[i])
    print(m)
    print(*G)
    global cnt
    print(cnt)
    for item in A:
        print(item) def shellSort(A, n):
    G = list()
    h = 1
    while h ==1 or h < n:
        G.append(h)
        h = h * 3 + 1
    G.reverse()
    m = len(G)
    for i in range(m):
        insertionSort(A, n, G[i])
    print(m)
    print(*G)
    global cnt
    print(cnt)
    for item in A:
        print(item) shellSort
import sys

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):
    G = list()
    h = 1
    while h ==1 or h < n:
        G.append(h)
        h = h * 3 + 1
    G.reverse()
    m = len(G)
    for i in range(m):
        insertionSort(A, n, G[i])
    print(m)
    print(*G)
    global cnt
    print(cnt)
    for item in A:
        print(item)

cnt = 0
n = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(n)]
shellSort(A, n)
