cnt = 0
m = 0
g = []

def insertion_sort(a, n, g):
# cnt+=1 のときにローカルスコープの外を見にいくようにするため
    global cnt
    for i in range(g, n):
        v = a[i]
        k = i - g
        while k >= 0 and a[k] > v:
            a[k+g] = a[k]
            k -= g
            cnt += 1
        a[k+g] = v

def shell_sort(a, n):
    global m, g
    h = 1
    while h <= n:
        g.append(h)
        h = h * 3 + 1
    g.reverse()
    m = len(g)
    for i in range(m):
        insertion_sort(a, n, g[i])

n = int(input())
a = [int(input()) for i in range(n)]
shell_sort(a, n)
print(m)
print(*g)
print(cnt)
for i in a:
    print(i) cnt = 0 cnt 0 m = 0 m 0 g = [] g [] def insertion_sort(a, n, g):
# cnt+=1 のときにローカルスコープの外を見にいくようにするため
    global cnt
    for i in range(g, n):
        v = a[i]
        k = i - g
        while k >= 0 and a[k] > v:
            a[k+g] = a[k]
            k -= g
            cnt += 1
        a[k+g] = v insertion_sort global cnt for i in range(g, n):
        v = a[i]
        k = i - g
        while k >= 0 and a[k] > v:
            a[k+g] = a[k]
            k -= g
            cnt += 1
        a[k+g] = v i range(g, n) range g n v = a[i] v a[i] a i k = i - g k i - g i g while k >= 0 and a[k] > v:
            a[k+g] = a[k]
            k -= g
            cnt += 1
         k >= 0 and a[k] > v k >= 0 k 0 a[k] > v a[k] a k v a[k+g] = a[k] a[k+g] a k+g k g a[k] a k k -= g k g cnt += 1 cnt 1 a[k+g] = v a[k+g] a k+g k g v a a n n g g def shell_sort(a, n):
    global m, g
    h = 1
    while h <= n:
        g.append(h)
        h = h * 3 + 1
    g.reverse()
    m = len(g)
    for i in range(m):
        insertion_sort(a, n, g[i]) shell_sort global m, g h = 1 h 1 while h <= n:
        g.append(h)
        h = h * 3 + 1
     h <= n h n g.append(h) g.append g append h h = h * 3 + 1 h h * 3 + 1 h * 3 h 3 1 g.reverse() g.reverse g reverse m = len(g) m len(g) len g for i in range(m):
        insertion_sort(a, n, g[i]) i range(m) range m insertion_sort(a, n, g[i]) insertion_sort a n g[i] g i a a n n n = int(input()) n int(input()) int input() input int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input a = [int(input()) for i in range(n)] a [int(input()) for i in range(n)] shell_sort(a, n) shell_sort a n print(m) print m print(*g) print *g g print(cnt) print cnt for i in a:
    print(i) i a print(i) print i cnt = 0 0 cnt m = 0 0 m g = [] [] g a = [int(input()) for i in range(n)] [int(input()) for i in range(n)] a def shell_sort(a, n):
    global m, g
    h = 1
    while h <= n:
        g.append(h)
        h = h * 3 + 1
    g.reverse()
    m = len(g)
    for i in range(m):
        insertion_sort(a, n, g[i]) def shell_sort(a, n):
    global m, g
    h = 1
    while h <= n:
        g.append(h)
        h = h * 3 + 1
    g.reverse()
    m = len(g)
    for i in range(m):
        insertion_sort(a, n, g[i]) shell_sort def insertion_sort(a, n, g):
# cnt+=1 のときにローカルスコープの外を見にいくようにするため
    global cnt
    for i in range(g, n):
        v = a[i]
        k = i - g
        while k >= 0 and a[k] > v:
            a[k+g] = a[k]
            k -= g
            cnt += 1
        a[k+g] = v def insertion_sort(a, n, g):
# cnt+=1 のときにローカルスコープの外を見にいくようにするため
    global cnt
    for i in range(g, n):
        v = a[i]
        k = i - g
        while k >= 0 and a[k] > v:
            a[k+g] = a[k]
            k -= g
            cnt += 1
        a[k+g] = v insertion_sort n = int(input()) int(input()) n
cnt = 0
m = 0
g = []

def insertion_sort(a, n, g):
# cnt+=1 のときにローカルスコープの外を見にいくようにするため
    global cnt
    for i in range(g, n):
        v = a[i]
        k = i - g
        while k >= 0 and a[k] > v:
            a[k+g] = a[k]
            k -= g
            cnt += 1
        a[k+g] = v

def shell_sort(a, n):
    global m, g
    h = 1
    while h <= n:
        g.append(h)
        h = h * 3 + 1
    g.reverse()
    m = len(g)
    for i in range(m):
        insertion_sort(a, n, g[i])

n = int(input())
a = [int(input()) for i in range(n)]
shell_sort(a, n)
print(m)
print(*g)
print(cnt)
for i in a:
    print(i)
