import sys

def shellSort(data, cnt, g, n):
    for idx in range(g, n):
        j = idx - g
        v = data[idx]
        while j >= 0 and data[j] > v:
            data[j+g] = data[j]
            j -= g
            cnt += 1
        data[j+g] = v
    return data, cnt

n, gap = int(input()), []
a = ([int(i) for i in sys.stdin.readlines()], 0)
g = 0
while g <= n//9:
    g = 3 * g + 1
    gap.append(g)
m = len(gap)
for i in gap[::-1]:
    a = shellSort(a[0], a[1], i, n)
print(m)
print(" ".join(map(str, gap[::-1])))
print(a[1])
for i in range(n):
    print(a[0][i])
 import sys sys def shellSort(data, cnt, g, n):
    for idx in range(g, n):
        j = idx - g
        v = data[idx]
        while j >= 0 and data[j] > v:
            data[j+g] = data[j]
            j -= g
            cnt += 1
        data[j+g] = v
    return data, cnt shellSort for idx in range(g, n):
        j = idx - g
        v = data[idx]
        while j >= 0 and data[j] > v:
            data[j+g] = data[j]
            j -= g
            cnt += 1
        data[j+g] = v
     idx range(g, n) range g n j = idx - g j idx - g idx g v = data[idx] v data[idx] data idx while j >= 0 and data[j] > v:
            data[j+g] = data[j]
            j -= g
            cnt += 1
         j >= 0 and data[j] > v j >= 0 j 0 data[j] > v data[j] data j v data[j+g] = data[j] data[j+g] data j+g j g data[j] data j j -= g j g cnt += 1 cnt 1 data[j+g] = v data[j+g] data j+g j g v return data, cnt return data, cnt data cnt data data cnt cnt g g n n n, gap = int(input()), [] n int(input()) int input() input gap [] int(i) for i in sys.stdin.readlines() for i in sys.stdin.readlines() i sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines for i in sys.stdin.readlines() int(i) int i a = ([int(i) for i in sys.stdin.readlines()], 0) a ([int(i) for i in sys.stdin.readlines()], 0) [int(i) for i in sys.stdin.readlines()] 0 g = 0 g 0 while g <= n//9:
    g = 3 * g + 1
    gap.append(g) g <= n//9 g n//9 n 9 g = 3 * g + 1 g 3 * g + 1 3 * g 3 g 1 gap.append(g) gap.append gap append g m = len(gap) m len(gap) len gap for i in gap[::-1]:
    a = shellSort(a[0], a[1], i, n) i gap[::-1] gap ::-1 -1 a = shellSort(a[0], a[1], i, n) a shellSort(a[0], a[1], i, n) shellSort a[0] a 0 a[1] a 1 i n print(m) print m print(" ".join(map(str, gap[::-1]))) print " ".join(map(str, gap[::-1])) " ".join " " join map(str, gap[::-1]) map str gap[::-1] gap ::-1 -1 print(a[1]) print a[1] a 1 for i in range(n):
    print(a[0][i]) i range(n) range n print(a[0][i]) print a[0][i] [0] a 0 i a = shellSort(a[0], a[1], i, n) shellSort(a[0], a[1], i, n) a n, gap = int(input()), [] int(input()) n gap = int(input()), [] [] gap g = 3 * g + 1 3 * g + 1 g def shellSort(data, cnt, g, n):
    for idx in range(g, n):
        j = idx - g
        v = data[idx]
        while j >= 0 and data[j] > v:
            data[j+g] = data[j]
            j -= g
            cnt += 1
        data[j+g] = v
    return data, cnt def shellSort(data, cnt, g, n):
    for idx in range(g, n):
        j = idx - g
        v = data[idx]
        while j >= 0 and data[j] > v:
            data[j+g] = data[j]
            j -= g
            cnt += 1
        data[j+g] = v
    return data, cnt shellSort a = ([int(i) for i in sys.stdin.readlines()], 0) ([int(i) for i in sys.stdin.readlines()], 0) a m = len(gap) len(gap) m g = 0 0 g
import sys

def shellSort(data, cnt, g, n):
    for idx in range(g, n):
        j = idx - g
        v = data[idx]
        while j >= 0 and data[j] > v:
            data[j+g] = data[j]
            j -= g
            cnt += 1
        data[j+g] = v
    return data, cnt

n, gap = int(input()), []
a = ([int(i) for i in sys.stdin.readlines()], 0)
g = 0
while g <= n//9:
    g = 3 * g + 1
    gap.append(g)
m = len(gap)
for i in gap[::-1]:
    a = shellSort(a[0], a[1], i, n)
print(m)
print(" ".join(map(str, gap[::-1])))
print(a[1])
for i in range(n):
    print(a[0][i])

