n = int(input())
A = [int(input()) for i in range(n)]

def getG(n):
    gn = 1
    G = [1]
    while 3*gn + 1 < n:
        gn = G[-1]*3 + 1
        G.append(gn)
    return G[::-1]

def insertionSort(A, n, g, cnt):
    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 A, cnt

def shellSort(A, n):
    G = getG(n)
    m = len(G)
    cnt = 0
    for i in range(m):
        A, cnt_l = insertionSort(A, n, G[i], cnt)
        cnt = cnt_l
    return A, m, G, cnt

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

def getG(n):
    gn = 1
    G = [1]
    while 3*gn + 1 < n:
        gn = G[-1]*3 + 1
        G.append(gn)
    return G[::-1]

def insertionSort(A, n, g, cnt):
    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 A, cnt

def shellSort(A, n):
    G = getG(n)
    m = len(G)
    cnt = 0
    for i in range(m):
        A, cnt_l = insertionSort(A, n, G[i], cnt)
        cnt = cnt_l
    return A, m, G, cnt

A, m, G, cnt = shellSort(A, n)
print(m)
print(" ".join([str(s) for s in G]))
print(cnt)
for a in A:
    print(a)
