#coding:utf-8

n = int(input())
A = [int(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 v < A[j]:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v
    return cnt



def shellSort(A,n):
    cnt = 0
    p = 1
    G = [p]
    while 3 * p + 1 < n:
        p = 3 * p + 1
        G.append(p)
    
    G.sort(reverse=True)
    m = len(G)
    for i in range(m):
        a = insertionSort(A,n,G[i])
        cnt += a
    print(m)
    G = " ".join([str(num) for num in G])
    print(G)
    print(cnt)

shellSort(A,n)
for num in A:
    print(num) 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)] def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and v < A[j]:
            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 v < A[j]:
            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 v < A[j]:
            A[j+g] = A[j]
            j -= g
            cnt += 1
         j >= 0 and v < A[j] j >= 0 j 0 v < A[j] v A[j] A j 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
    p = 1
    G = [p]
    while 3 * p + 1 < n:
        p = 3 * p + 1
        G.append(p)
    
    G.sort(reverse=True)
    m = len(G)
    for i in range(m):
        a = insertionSort(A,n,G[i])
        cnt += a
    print(m)
    G = " ".join([str(num) for num in G])
    print(G)
    print(cnt) shellSort cnt = 0 cnt 0 p = 1 p 1 G = [p] G [p] p while 3 * p + 1 < n:
        p = 3 * p + 1
        G.append(p)
    
     3 * p + 1 < n 3 * p + 1 3 * p 3 p 1 n p = 3 * p + 1 p 3 * p + 1 3 * p 3 p 1 G.append(p) G.append G append p G.sort(reverse=True) G.sort G sort reverse=True reverse True m = len(G) m len(G) len G for i in range(m):
        a = insertionSort(A,n,G[i])
        cnt += a
     i range(m) range m a = insertionSort(A,n,G[i]) a insertionSort(A,n,G[i]) insertionSort A n G[i] G i cnt += a cnt a print(m) print m str(num) for num in G for num in G num G for num in G str(num) str num G = " ".join([str(num) for num in G]) G " ".join([str(num) for num in G]) " ".join " " join [str(num) for num in G] print(G) print G print(cnt) print cnt A A n n shellSort(A,n) shellSort A n for num in A:
    print(num) num A print(num) print num A = [int(input()) for i in range(n)] [int(input()) for i in range(n)] A def shellSort(A,n):
    cnt = 0
    p = 1
    G = [p]
    while 3 * p + 1 < n:
        p = 3 * p + 1
        G.append(p)
    
    G.sort(reverse=True)
    m = len(G)
    for i in range(m):
        a = insertionSort(A,n,G[i])
        cnt += a
    print(m)
    G = " ".join([str(num) for num in G])
    print(G)
    print(cnt) def shellSort(A,n):
    cnt = 0
    p = 1
    G = [p]
    while 3 * p + 1 < n:
        p = 3 * p + 1
        G.append(p)
    
    G.sort(reverse=True)
    m = len(G)
    for i in range(m):
        a = insertionSort(A,n,G[i])
        cnt += a
    print(m)
    G = " ".join([str(num) for num in G])
    print(G)
    print(cnt) shellSort def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and v < A[j]:
            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 v < A[j]:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v
    return cnt insertionSort n = int(input()) int(input()) n
#coding:utf-8

n = int(input())
A = [int(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 v < A[j]:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v
    return cnt



def shellSort(A,n):
    cnt = 0
    p = 1
    G = [p]
    while 3 * p + 1 < n:
        p = 3 * p + 1
        G.append(p)
    
    G.sort(reverse=True)
    m = len(G)
    for i in range(m):
        a = insertionSort(A,n,G[i])
        cnt += a
    print(m)
    G = " ".join([str(num) for num in G])
    print(G)
    print(cnt)

shellSort(A,n)
for num in A:
    print(num)
