# shell sort

def insertion_sort(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 = j - g
            cnt += 1
        a[j+g] = v

    return cnt


def shell_sort(a, n, G, cnt):
    for i in range(m):
        cnt = insertion_sort(a, n, G[i], cnt)
    return cnt


# input
N = int(input())
nums = [0]*N
for i in range(N):
    nums[i] = int(input())

# initialization
G = [1]
h = 1
while h<N:
    h = 3*h + 1
while h>1:
    h = (h - 1) // 3
    G.append(h)
G = sorted(list(set(G)), reverse=True)
m = len(G)
cnt = 0

# sorting
cnt = shell_sort(nums, N, G, cnt)

# output
print(m)
print(" ".join(map(str, G)))
print(cnt)
for i in range(N):
    print(nums[i])
 def insertion_sort(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 = j - g
            cnt += 1
        a[j+g] = v

    return cnt insertion_sort 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 = 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 = 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 = j - g j j - g j g cnt += 1 cnt 1 a[j+g] = v a[j+g] a j+g j g v return cnt cnt a a n n g g cnt cnt def shell_sort(a, n, G, cnt):
    for i in range(m):
        cnt = insertion_sort(a, n, G[i], cnt)
    return cnt


# input shell_sort for i in range(m):
        cnt = insertion_sort(a, n, G[i], cnt)
     i range(m) range m cnt = insertion_sort(a, n, G[i], cnt) cnt insertion_sort(a, n, G[i], cnt) insertion_sort a n G[i] G i cnt return cnt cnt a a n n G G cnt cnt N = int(input()) N int(input()) int input() input nums = [0]*N nums [0]*N [0] 0 N for i in range(N):
    nums[i] = int(input())

# initialization i range(N) range N nums[i] = int(input()) nums[i] nums i int(input()) int input() input G = [1] G [1] 1 h = 1 h 1 while h<N:
    h = 3*h + 1 h<N h N h = 3*h + 1 h 3*h + 1 3*h 3 h 1 while h>1:
    h = (h - 1) // 3
    G.append(h) h>1 h 1 h = (h - 1) // 3 h (h - 1) // 3 h - 1 h 1 3 G.append(h) G.append G append h G = sorted(list(set(G)), reverse=True) G sorted(list(set(G)), reverse=True) sorted list(set(G)) list set(G) set G reverse=True reverse True m = len(G) m len(G) len G cnt = 0 cnt 0 cnt = shell_sort(nums, N, G, cnt) cnt shell_sort(nums, N, G, cnt) shell_sort nums N G cnt 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 i in range(N):
    print(nums[i]) i range(N) range N print(nums[i]) print nums[i] nums i cnt = shell_sort(nums, N, G, cnt) shell_sort(nums, N, G, cnt) cnt nums = [0]*N [0]*N nums m = len(G) len(G) m def insertion_sort(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 = j - g
            cnt += 1
        a[j+g] = v

    return cnt def insertion_sort(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 = j - g
            cnt += 1
        a[j+g] = v

    return cnt insertion_sort def shell_sort(a, n, G, cnt):
    for i in range(m):
        cnt = insertion_sort(a, n, G[i], cnt)
    return cnt


# input def shell_sort(a, n, G, cnt):
    for i in range(m):
        cnt = insertion_sort(a, n, G[i], cnt)
    return cnt


# input shell_sort h = 1 1 h G = [1] [1] G G = sorted(list(set(G)), reverse=True) sorted(list(set(G)), reverse=True) G h = 3*h + 1 3*h + 1 h N = int(input()) int(input()) N cnt = 0 0 cnt h = (h - 1) // 3 (h - 1) // 3 h
# shell sort

def insertion_sort(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 = j - g
            cnt += 1
        a[j+g] = v

    return cnt


def shell_sort(a, n, G, cnt):
    for i in range(m):
        cnt = insertion_sort(a, n, G[i], cnt)
    return cnt


# input
N = int(input())
nums = [0]*N
for i in range(N):
    nums[i] = int(input())

# initialization
G = [1]
h = 1
while h<N:
    h = 3*h + 1
while h>1:
    h = (h - 1) // 3
    G.append(h)
G = sorted(list(set(G)), reverse=True)
m = len(G)
cnt = 0

# sorting
cnt = shell_sort(nums, N, G, cnt)

# output
print(m)
print(" ".join(map(str, G)))
print(cnt)
for i in range(N):
    print(nums[i])

