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

def shellSort(a,n):
    global m
    global g
    h = 1
    while True:
        if h>n:
            break
        g.append(h)
        h = 3*h+1
    m = len(g)
    g.reverse()
    for i in range(m):
        insertionSort(a,n,g[i])

n = int(input())
a = [int(input()) for i in range(n)]
g = []
cnt = 0
m = 0
shellSort(a,n)
print(m)
print(*g)
print(cnt)
for i in range(n):
    print(a[i])
 def insertionSort(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 = j-g
            cnt+=1
        a[j+g] = v insertionSort 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 = 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 a a n n g g def shellSort(a,n):
    global m
    global g
    h = 1
    while True:
        if h>n:
            break
        g.append(h)
        h = 3*h+1
    m = len(g)
    g.reverse()
    for i in range(m):
        insertionSort(a,n,g[i]) shellSort global m global g h = 1 h 1 while True:
        if h>n:
            break
        g.append(h)
        h = 3*h+1
     True if h>n:
            break
         h>n h n break g.append(h) g.append g append h h = 3*h+1 h 3*h+1 3*h 3 h 1 m = len(g) m len(g) len g g.reverse() g.reverse g reverse for i in range(m):
        insertionSort(a,n,g[i]) i range(m) range m insertionSort(a,n,g[i]) insertionSort 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)] g = [] g [] cnt = 0 cnt 0 m = 0 m 0 shellSort(a,n) shellSort a n print(m) print m print(*g) print *g g print(cnt) print cnt for i in range(n):
    print(a[i]) i range(n) range n print(a[i]) print a[i] a i def shellSort(a,n):
    global m
    global g
    h = 1
    while True:
        if h>n:
            break
        g.append(h)
        h = 3*h+1
    m = len(g)
    g.reverse()
    for i in range(m):
        insertionSort(a,n,g[i]) def shellSort(a,n):
    global m
    global g
    h = 1
    while True:
        if h>n:
            break
        g.append(h)
        h = 3*h+1
    m = len(g)
    g.reverse()
    for i in range(m):
        insertionSort(a,n,g[i]) shellSort n = int(input()) int(input()) n cnt = 0 0 cnt def insertionSort(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 = j-g
            cnt+=1
        a[j+g] = v def insertionSort(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 = j-g
            cnt+=1
        a[j+g] = v insertionSort g = [] [] g a = [int(input()) for i in range(n)] [int(input()) for i in range(n)] a m = 0 0 m
def insertionSort(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 = j-g
            cnt+=1
        a[j+g] = v

def shellSort(a,n):
    global m
    global g
    h = 1
    while True:
        if h>n:
            break
        g.append(h)
        h = 3*h+1
    m = len(g)
    g.reverse()
    for i in range(m):
        insertionSort(a,n,g[i])

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

