import math

def insertion(a, n, g, cnt):
    for i in range(g, n):
        v = a[i]
        j  = i - g
        while v < a[j] and j >= 0:
            a[j+g] = a[j]
            j -= g
            cnt += 1
        else:
            a[j+g] = v
    else:
        return cnt

def shell(a, n):
    cnt = 0
    m = 9
    G = [100000, 11000, 1017, 107, 48, 25, 12, 7, 3, 1]
    for g in G:
        cnt = insertion(a, n, g, cnt)
    else:
        return cnt, m, G

def print_space(li, n):
    m = 0
    for i in range(len(li)-1):
        if li[i] <= n:
            print(li[i], end=' ')
            m += 1
    else:
        print(li[-1])
        m += 1
        return m

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


res = shell(a, n)

cnt = res[0]
G = res[2]

m = 0

for i in range(len(G)):
    if G[i] <= n:
        m += 1


print(m)
print_space(G, n)
print(cnt)
for i in a:
    print(i)


 import math math def insertion(a, n, g, cnt):
    for i in range(g, n):
        v = a[i]
        j  = i - g
        while v < a[j] and j >= 0:
            a[j+g] = a[j]
            j -= g
            cnt += 1
        else:
            a[j+g] = v
    else:
        return cnt insertion for i in range(g, n):
        v = a[i]
        j  = i - g
        while v < a[j] and j >= 0:
            a[j+g] = a[j]
            j -= g
            cnt += 1
        else:
            a[j+g] = v
    else:
        return cnt i range(g, n) range g n v = a[i] v a[i] a i j  = i - g j i - g i g while v < a[j] and j >= 0:
            a[j+g] = a[j]
            j -= g
            cnt += 1
        else:
            a[j+g] = v
     v < a[j] and j >= 0 v < a[j] v a[j] a j j >= 0 j 0 a[j+g] = a[j] a[j+g] a j+g j g a[j] a 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(a, n):
    cnt = 0
    m = 9
    G = [100000, 11000, 1017, 107, 48, 25, 12, 7, 3, 1]
    for g in G:
        cnt = insertion(a, n, g, cnt)
    else:
        return cnt, m, G shell cnt = 0 cnt 0 m = 9 m 9 G = [100000, 11000, 1017, 107, 48, 25, 12, 7, 3, 1] G [100000, 11000, 1017, 107, 48, 25, 12, 7, 3, 1] 100000 11000 1017 107 48 25 12 7 3 1 for g in G:
        cnt = insertion(a, n, g, cnt)
    else:
        return cnt, m, G g G cnt = insertion(a, n, g, cnt) cnt insertion(a, n, g, cnt) insertion a n g cnt return cnt, m, G return cnt, m, G cnt m G a a n n def print_space(li, n):
    m = 0
    for i in range(len(li)-1):
        if li[i] <= n:
            print(li[i], end=' ')
            m += 1
    else:
        print(li[-1])
        m += 1
        return m print_space m = 0 m 0 for i in range(len(li)-1):
        if li[i] <= n:
            print(li[i], end=' ')
            m += 1
    else:
        print(li[-1])
        m += 1
        return m i range(len(li)-1) range len(li)-1 len(li) len li 1 if li[i] <= n:
            print(li[i], end=' ')
            m += 1
     li[i] <= n li[i] li i n print(li[i], end=' ') print li[i] li i end=' ' end ' ' m += 1 m 1 print(li[-1]) print li[-1] li -1 m += 1 m 1 return m m li li 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)] res = shell(a, n) res shell(a, n) shell a n cnt = res[0] cnt res[0] res 0 G = res[2] G res[2] res 2 m = 0 m 0 for i in range(len(G)):
    if G[i] <= n:
        m += 1 i range(len(G)) range len(G) len G if G[i] <= n:
        m += 1 G[i] <= n G[i] G i n m += 1 m 1 print(m) print m print_space(G, n) print_space G n print(cnt) print cnt for i in a:
    print(i) i a print(i) print i m += 1 1 m def shell(a, n):
    cnt = 0
    m = 9
    G = [100000, 11000, 1017, 107, 48, 25, 12, 7, 3, 1]
    for g in G:
        cnt = insertion(a, n, g, cnt)
    else:
        return cnt, m, G def shell(a, n):
    cnt = 0
    m = 9
    G = [100000, 11000, 1017, 107, 48, 25, 12, 7, 3, 1]
    for g in G:
        cnt = insertion(a, n, g, cnt)
    else:
        return cnt, m, G shell def print_space(li, n):
    m = 0
    for i in range(len(li)-1):
        if li[i] <= n:
            print(li[i], end=' ')
            m += 1
    else:
        print(li[-1])
        m += 1
        return m def print_space(li, n):
    m = 0
    for i in range(len(li)-1):
        if li[i] <= n:
            print(li[i], end=' ')
            m += 1
    else:
        print(li[-1])
        m += 1
        return m print_space G = res[2] res[2] G def insertion(a, n, g, cnt):
    for i in range(g, n):
        v = a[i]
        j  = i - g
        while v < a[j] and j >= 0:
            a[j+g] = a[j]
            j -= g
            cnt += 1
        else:
            a[j+g] = v
    else:
        return cnt def insertion(a, n, g, cnt):
    for i in range(g, n):
        v = a[i]
        j  = i - g
        while v < a[j] and j >= 0:
            a[j+g] = a[j]
            j -= g
            cnt += 1
        else:
            a[j+g] = v
    else:
        return cnt insertion cnt = res[0] res[0] cnt a = [int(input()) for i in range(n)] [int(input()) for i in range(n)] a m = 0 0 m n = int(input()) int(input()) n res = shell(a, n) shell(a, n) res
import math

def insertion(a, n, g, cnt):
    for i in range(g, n):
        v = a[i]
        j  = i - g
        while v < a[j] and j >= 0:
            a[j+g] = a[j]
            j -= g
            cnt += 1
        else:
            a[j+g] = v
    else:
        return cnt

def shell(a, n):
    cnt = 0
    m = 9
    G = [100000, 11000, 1017, 107, 48, 25, 12, 7, 3, 1]
    for g in G:
        cnt = insertion(a, n, g, cnt)
    else:
        return cnt, m, G

def print_space(li, n):
    m = 0
    for i in range(len(li)-1):
        if li[i] <= n:
            print(li[i], end=' ')
            m += 1
    else:
        print(li[-1])
        m += 1
        return m

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


res = shell(a, n)

cnt = res[0]
G = res[2]

m = 0

for i in range(len(G)):
    if G[i] <= n:
        m += 1


print(m)
print_space(G, n)
print(cnt)
for i in a:
    print(i)



