def ins(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 shell(a,n):
    global cnt
    cnt = 0 
    h = 1 
    G=[]
    while h <= n:
        G.append(h)
        h = 3*h +1
    G.reverse()
    m = len(G)
    print(m)
    print(" ".join(map(str, G)))

    for i in range(m):
        ins(a, n, G[i])

intn = int(input())
a = [int(input()) for i in range(intn)]

shell(a,intn)
print(cnt)
for w in a:
    print(w) def ins(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 ins 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
            a[j+g] = v 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 shell(a,n):
    global cnt
    cnt = 0 
    h = 1 
    G=[]
    while h <= n:
        G.append(h)
        h = 3*h +1
    G.reverse()
    m = len(G)
    print(m)
    print(" ".join(map(str, G)))

    for i in range(m):
        ins(a, n, G[i]) shell global cnt cnt = 0 cnt 0 h = 1 h 1 G=[] G [] while h <= n:
        G.append(h)
        h = 3*h +1
     h <= n h n G.append(h) G.append G append h h = 3*h +1 h 3*h +1 3*h 3 h 1 G.reverse() G.reverse G reverse m = len(G) m len(G) len G print(m) print m print(" ".join(map(str, G))) print " ".join(map(str, G)) " ".join " " join map(str, G) map str G for i in range(m):
        ins(a, n, G[i]) i range(m) range m ins(a, n, G[i]) ins a n G[i] G i a a n n intn = int(input()) intn int(input()) int input() input int(input()) for i in range(intn) for i in range(intn) i range(intn) range intn for i in range(intn) int(input()) int input() input a = [int(input()) for i in range(intn)] a [int(input()) for i in range(intn)] shell(a,intn) shell a intn print(cnt) print cnt for w in a:
    print(w) w a print(w) print w def ins(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 ins(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 ins intn = int(input()) int(input()) intn a = [int(input()) for i in range(intn)] [int(input()) for i in range(intn)] a def shell(a,n):
    global cnt
    cnt = 0 
    h = 1 
    G=[]
    while h <= n:
        G.append(h)
        h = 3*h +1
    G.reverse()
    m = len(G)
    print(m)
    print(" ".join(map(str, G)))

    for i in range(m):
        ins(a, n, G[i]) def shell(a,n):
    global cnt
    cnt = 0 
    h = 1 
    G=[]
    while h <= n:
        G.append(h)
        h = 3*h +1
    G.reverse()
    m = len(G)
    print(m)
    print(" ".join(map(str, G)))

    for i in range(m):
        ins(a, n, G[i]) shell
def ins(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 shell(a,n):
    global cnt
    cnt = 0 
    h = 1 
    G=[]
    while h <= n:
        G.append(h)
        h = 3*h +1
    G.reverse()
    m = len(G)
    print(m)
    print(" ".join(map(str, G)))

    for i in range(m):
        ins(a, n, G[i])

intn = int(input())
a = [int(input()) for i in range(intn)]

shell(a,intn)
print(cnt)
for w in a:
    print(w)