n = int(input())
A = [int(input()) for _ in range(n)]
G = [1]
a=1
while True:
    a = 3*a+1
    if a>=n:
        break
    G.append(a)
if len(G)>1:
    G.sort(reverse=True)
m = len(G)
cnt = 0

def shellSort(A,n):
    cccnt = 0
    for k in range(m):
        cccnt += insertionSort(A,n,G[k])
    return cccnt

def insertionSort(A,n,g): #Aはリスト　nは要素数　gは間隔
    ccnt = 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 -= g
            ccnt += 1
        A[j+g] = v
    return ccnt

cnt = shellSort(A,n)

print(m)
print(' '.join(map(str,G)))
print(cnt)
for _ in range(n):
    print(A[_]) 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)] G = [1] G [1] 1 a=1 a 1 while True:
    a = 3*a+1
    if a>=n:
        break
    G.append(a) True a = 3*a+1 a 3*a+1 3*a 3 a 1 if a>=n:
        break
     a>=n a n break G.append(a) G.append G append a if len(G)>1:
    G.sort(reverse=True) len(G)>1 len(G) len G 1 G.sort(reverse=True) G.sort G sort reverse=True reverse True m = len(G) m len(G) len G cnt = 0 cnt 0 def shellSort(A,n):
    cccnt = 0
    for k in range(m):
        cccnt += insertionSort(A,n,G[k])
    return cccnt shellSort cccnt = 0 cccnt 0 for k in range(m):
        cccnt += insertionSort(A,n,G[k])
     k range(m) range m cccnt += insertionSort(A,n,G[k]) cccnt insertionSort(A,n,G[k]) insertionSort A n G[k] G k return cccnt cccnt A A n n def insertionSort(A,n,g): #Aはリスト　nは要素数　gは間隔
    ccnt = 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 -= g
            ccnt += 1
        A[j+g] = v
    return ccnt insertionSort ccnt = 0 ccnt 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 -= g
            ccnt += 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
            ccnt += 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 ccnt += 1 ccnt 1 A[j+g] = v A[j+g] A j+g j g v return ccnt ccnt A A n n g g cnt = shellSort(A,n) cnt shellSort(A,n) shellSort A n 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 _ in range(n):
    print(A[_]) _ range(n) range n print(A[_]) print A[_] A _ def shellSort(A,n):
    cccnt = 0
    for k in range(m):
        cccnt += insertionSort(A,n,G[k])
    return cccnt def shellSort(A,n):
    cccnt = 0
    for k in range(m):
        cccnt += insertionSort(A,n,G[k])
    return cccnt shellSort A = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] A G = [1] [1] G n = int(input()) int(input()) n a = 3*a+1 3*a+1 a cnt = 0 0 cnt a=1 1 a cnt = shellSort(A,n) shellSort(A,n) cnt def insertionSort(A,n,g): #Aはリスト　nは要素数　gは間隔
    ccnt = 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 -= g
            ccnt += 1
        A[j+g] = v
    return ccnt def insertionSort(A,n,g): #Aはリスト　nは要素数　gは間隔
    ccnt = 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 -= g
            ccnt += 1
        A[j+g] = v
    return ccnt insertionSort m = len(G) len(G) m
n = int(input())
A = [int(input()) for _ in range(n)]
G = [1]
a=1
while True:
    a = 3*a+1
    if a>=n:
        break
    G.append(a)
if len(G)>1:
    G.sort(reverse=True)
m = len(G)
cnt = 0

def shellSort(A,n):
    cccnt = 0
    for k in range(m):
        cccnt += insertionSort(A,n,G[k])
    return cccnt

def insertionSort(A,n,g): #Aはリスト　nは要素数　gは間隔
    ccnt = 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 -= g
            ccnt += 1
        A[j+g] = v
    return ccnt

cnt = shellSort(A,n)

print(m)
print(' '.join(map(str,G)))
print(cnt)
for _ in range(n):
    print(A[_])
