def insertionSort(A, n, g):
    cnt = 0
    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 = cnt + 1
        A[j+g] = v
    return cnt

n = int(input())
a = []
g = []
for i in range(n):
    x = int(input())
    a.append(x)
count = 0
m = 1;
while m<= n:
    g.append(m)
    m = (m*3) + 1
l = len(g)
print(str(l))
l = l-1
while l>0:
    print(str(g[l]) + " ", end = '')
    count += insertionSort(a, n, g[l])
    l = l-1
print(str(g[l]))
count += insertionSort(a, n, g[l])
print(str(count))
for i in a:
    print(str(i))
 def insertionSort(A, n, g):
    cnt = 0
    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 = cnt + 1
        A[j+g] = v
    return cnt insertionSort cnt = 0 cnt 0 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 = 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 = 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 = cnt + 1 cnt 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 n = int(input()) n int(input()) int input() input a = [] a [] g = [] g [] for i in range(n):
    x = int(input())
    a.append(x) i range(n) range n x = int(input()) x int(input()) int input() input a.append(x) a.append a append x count = 0 count 0 m = 1 m 1 while m<= n:
    g.append(m)
    m = (m*3) + 1 m<= n m n g.append(m) g.append g append m m = (m*3) + 1 m (m*3) + 1 m*3 m 3 1 l = len(g) l len(g) len g print(str(l)) print str(l) str l l = l-1 l l-1 l 1 while l>0:
    print(str(g[l]) + " ", end = '')
    count += insertionSort(a, n, g[l])
    l = l-1 l>0 l 0 print(str(g[l]) + " ", end = '') print str(g[l]) + " " str(g[l]) str g[l] g l " " end = '' end '' count += insertionSort(a, n, g[l]) count insertionSort(a, n, g[l]) insertionSort a n g[l] g l l = l-1 l l-1 l 1 print(str(g[l])) print str(g[l]) str g[l] g l count += insertionSort(a, n, g[l]) count insertionSort(a, n, g[l]) insertionSort a n g[l] g l print(str(count)) print str(count) str count for i in a:
    print(str(i)) i a print(str(i)) print str(i) str i x = int(input()) int(input()) x n = int(input()) int(input()) n count += insertionSort(a, n, g[l]) insertionSort(a, n, g[l]) count def insertionSort(A, n, g):
    cnt = 0
    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 = cnt + 1
        A[j+g] = v
    return cnt def insertionSort(A, n, g):
    cnt = 0
    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 = cnt + 1
        A[j+g] = v
    return cnt insertionSort g = [] [] g m = (m*3) + 1 (m*3) + 1 m l = l-1 l-1 l m = 1 1 m count = 0 0 count count += insertionSort(a, n, g[l]) insertionSort(a, n, g[l]) count l = len(g) len(g) l a = [] [] a l = l-1 l-1 l
def insertionSort(A, n, g):
    cnt = 0
    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 = cnt + 1
        A[j+g] = v
    return cnt

n = int(input())
a = []
g = []
for i in range(n):
    x = int(input())
    a.append(x)
count = 0
m = 1;
while m<= n:
    g.append(m)
    m = (m*3) + 1
l = len(g)
print(str(l))
l = l-1
while l>0:
    print(str(g[l]) + " ", end = '')
    count += insertionSort(a, n, g[l])
    l = l-1
print(str(g[l]))
count += insertionSort(a, n, g[l])
print(str(count))
for i in a:
    print(str(i))

