import sys
 
def isort(a, n, g):
    global 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
 
# input data
n = int(sys.stdin.readline())
a = []
for i in range(n):
    a.append(int(sys.stdin.readline()))
 
# determine m, g
g = [1]
m = 1
while True:
    x = 3 * g[m - 1] + 1
    if x >= n: break
    g.append(x)
    m += 1
g = g[::-1]
 
# 1 output m
print(m)
# 2 output g
print(' '.join(map(str, g)))
 
# sort it
cnt = 0
for i in range(m):
    isort(a, n, g[i])
 
# 3 output cnt
print(cnt)
# 4 output sorted a
print('\n'.join(map(str, a))) import sys sys def isort(a, n, g):
    global 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
 
# input data isort global 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
 
# input data 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 a a n n g g n = int(sys.stdin.readline()) n int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline a = [] a [] for i in range(n):
    a.append(int(sys.stdin.readline()))
 
# determine m, g i range(n) range n a.append(int(sys.stdin.readline())) a.append a append int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline g = [1] g [1] 1 m = 1 m 1 while True:
    x = 3 * g[m - 1] + 1
    if x >= n: break
    g.append(x)
    m += 1 True x = 3 * g[m - 1] + 1 x 3 * g[m - 1] + 1 3 * g[m - 1] 3 g[m - 1] g m - 1 m 1 1 if x >= n: break
     x >= n x n g.append(x) g.append g append x m += 1 m 1 g = g[::-1] g g[::-1] g ::-1 -1 print(m) print m print(' '.join(map(str, g))) print ' '.join(map(str, g)) ' '.join ' ' join map(str, g) map str g cnt = 0 cnt 0 for i in range(m):
    isort(a, n, g[i])
 
# 3 output cnt i range(m) range m isort(a, n, g[i]) isort a n g[i] g i print(cnt) print cnt print('\n'.join(map(str, a))) print '\n'.join(map(str, a)) '\n'.join '\n' join map(str, a) map str a def isort(a, n, g):
    global 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
 
# input data def isort(a, n, g):
    global 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
 
# input data isort g = g[::-1] g[::-1] g cnt = 0 0 cnt a = [] [] a m += 1 1 m n = int(sys.stdin.readline()) int(sys.stdin.readline()) n x = 3 * g[m - 1] + 1 3 * g[m - 1] + 1 x m = 1 1 m g = [1] [1] g
import sys
 
def isort(a, n, g):
    global 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
 
# input data
n = int(sys.stdin.readline())
a = []
for i in range(n):
    a.append(int(sys.stdin.readline()))
 
# determine m, g
g = [1]
m = 1
while True:
    x = 3 * g[m - 1] + 1
    if x >= n: break
    g.append(x)
    m += 1
g = g[::-1]
 
# 1 output m
print(m)
# 2 output g
print(' '.join(map(str, g)))
 
# sort it
cnt = 0
for i in range(m):
    isort(a, n, g[i])
 
# 3 output cnt
print(cnt)
# 4 output sorted a
print('\n'.join(map(str, a)))