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 -= g
            cnt += 1
        A[j+g] = v

    return(A, cnt)

def ShellSort(A, n):
    cnt = 0
    for i in range(m):
        A, cnt = InsertionSort(A , n, G[i], cnt)
    
    return(A, cnt)

n = int(input())
A = []

G = []
g = 1
while g <= n:
    G.append(g)
    g = g*3 + 1
G.reverse()
m = len(G)


for i in range(n):
    a = int(input())
    A.append(a)

A, c = ShellSort(A, n)

print(m)
print(' '.join(map(str, G)))
print(c)
for i in range(n):
    print(A[i]) 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 -= 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 -= 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 -= g
            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 cnt += 1 cnt 1 A[j+g] = v A[j+g] A j+g j g v return(A, cnt) (A, cnt) A cnt A A N N g g cnt cnt def ShellSort(A, n):
    cnt = 0
    for i in range(m):
        A, cnt = InsertionSort(A , n, G[i], cnt)
    
    return(A, cnt) ShellSort cnt = 0 cnt 0 for i in range(m):
        A, cnt = InsertionSort(A , n, G[i], cnt)
    
     i range(m) range m A, cnt = InsertionSort(A , n, G[i], cnt) A InsertionSort(A , n, G[i], cnt) InsertionSort A n G[i] G i cnt cnt return(A, cnt) (A, cnt) A cnt A A n n n = int(input()) n int(input()) int input() input A = [] A [] G = [] G [] g = 1 g 1 while g <= n:
    G.append(g)
    g = g*3 + 1 g <= n g n G.append(g) G.append G append g g = g*3 + 1 g g*3 + 1 g*3 g 3 1 G.reverse() G.reverse G reverse m = len(G) m len(G) len G for i in range(n):
    a = int(input())
    A.append(a) i range(n) range n a = int(input()) a int(input()) int input() input A.append(a) A.append A append a A, c = ShellSort(A, n) A ShellSort(A, n) ShellSort A n c print(m) print m print(' '.join(map(str, G))) print ' '.join(map(str, G)) ' '.join ' ' join map(str, G) map str G print(c) print c for i in range(n):
    print(A[i]) i range(n) range n print(A[i]) print A[i] A i m = len(G) len(G) m c = ShellSort(A, n) ShellSort(A, n) c def ShellSort(A, n):
    cnt = 0
    for i in range(m):
        A, cnt = InsertionSort(A , n, G[i], cnt)
    
    return(A, cnt) def ShellSort(A, n):
    cnt = 0
    for i in range(m):
        A, cnt = InsertionSort(A , n, G[i], cnt)
    
    return(A, cnt) ShellSort 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 -= 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 -= g
            cnt += 1
        A[j+g] = v

    return(A, cnt) InsertionSort A = [] [] A g = 1 1 g n = int(input()) int(input()) n a = int(input()) int(input()) a G = [] [] G g = g*3 + 1 g*3 + 1 g A, c = ShellSort(A, n) ShellSort(A, n) A
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 -= g
            cnt += 1
        A[j+g] = v

    return(A, cnt)

def ShellSort(A, n):
    cnt = 0
    for i in range(m):
        A, cnt = InsertionSort(A , n, G[i], cnt)
    
    return(A, cnt)

n = int(input())
A = []

G = []
g = 1
while g <= n:
    G.append(g)
    g = g*3 + 1
G.reverse()
m = len(G)


for i in range(n):
    a = int(input())
    A.append(a)

A, c = ShellSort(A, n)

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