def insertionSortG(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 -= g
            global cnt
            cnt += 1
        a[j+g] = v

def shellSort(a, n):
    G = []
    i = 0
    while 3 * i + 1 <= n:
        i = 3 * i + 1
        G.append(i)
    G.sort(reverse=True)
    for g in G:
        insertionSortG(a, n, g)
    G = [str(s) for s in G]
    print(len(G))
    print(' '.join(G))

n = int(input())
a = [int(input()) for _ in range(n)]
cnt = 0

shellSort(a, n)
print(cnt)
for s in a:
    print(s) def insertionSortG(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 -= g
            global cnt
            cnt += 1
        a[j+g] = v insertionSortG 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 -= 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 -= 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 -= 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 = []
    i = 0
    while 3 * i + 1 <= n:
        i = 3 * i + 1
        G.append(i)
    G.sort(reverse=True)
    for g in G:
        insertionSortG(a, n, g)
    G = [str(s) for s in G]
    print(len(G))
    print(' '.join(G)) shellSort G = [] G [] i = 0 i 0 while 3 * i + 1 <= n:
        i = 3 * i + 1
        G.append(i)
     3 * i + 1 <= n 3 * i + 1 3 * i 3 i 1 n i = 3 * i + 1 i 3 * i + 1 3 * i 3 i 1 G.append(i) G.append G append i G.sort(reverse=True) G.sort G sort reverse=True reverse True for g in G:
        insertionSortG(a, n, g)
     g G insertionSortG(a, n, g) insertionSortG a n g str(s) for s in G for s in G s G for s in G str(s) str s G = [str(s) for s in G] G [str(s) for s in G] print(len(G)) print len(G) len G print(' '.join(G)) print ' '.join(G) ' '.join ' ' join G a a n n n = int(input()) n int(input()) int input() input int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input a = [int(input()) for _ in range(n)] a [int(input()) for _ in range(n)] cnt = 0 cnt 0 shellSort(a, n) shellSort a n print(cnt) print cnt for s in a:
    print(s) s a print(s) print s n = int(input()) int(input()) n def insertionSortG(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 -= g
            global cnt
            cnt += 1
        a[j+g] = v def insertionSortG(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 -= g
            global cnt
            cnt += 1
        a[j+g] = v insertionSortG def shellSort(a, n):
    G = []
    i = 0
    while 3 * i + 1 <= n:
        i = 3 * i + 1
        G.append(i)
    G.sort(reverse=True)
    for g in G:
        insertionSortG(a, n, g)
    G = [str(s) for s in G]
    print(len(G))
    print(' '.join(G)) def shellSort(a, n):
    G = []
    i = 0
    while 3 * i + 1 <= n:
        i = 3 * i + 1
        G.append(i)
    G.sort(reverse=True)
    for g in G:
        insertionSortG(a, n, g)
    G = [str(s) for s in G]
    print(len(G))
    print(' '.join(G)) shellSort cnt = 0 0 cnt a = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] a
def insertionSortG(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 -= g
            global cnt
            cnt += 1
        a[j+g] = v

def shellSort(a, n):
    G = []
    i = 0
    while 3 * i + 1 <= n:
        i = 3 * i + 1
        G.append(i)
    G.sort(reverse=True)
    for g in G:
        insertionSortG(a, n, g)
    G = [str(s) for s in G]
    print(len(G))
    print(' '.join(G))

n = int(input())
a = [int(input()) for _ in range(n)]
cnt = 0

shellSort(a, n)
print(cnt)
for s in a:
    print(s)
