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

def shell_sort(a, n):
    cnt = 0
    g = []
    h = 1
    while h <= n:
        g.append(h)
        h = 3 * h + 1
    g.reverse()
    m = len(g)
    print(m)
    print(*g)
    for i in range(m):
        cnt += insertion_sort(a, g[i], n)
    print(cnt)

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

shell_sort(a, n)
print('\n'.join(map(str, a)))
 def insertion_sort(a, g, n):
    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 += 1
        a[j + g] = v
    return cnt insertion_sort 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 += 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 g g n n def shell_sort(a, n):
    cnt = 0
    g = []
    h = 1
    while h <= n:
        g.append(h)
        h = 3 * h + 1
    g.reverse()
    m = len(g)
    print(m)
    print(*g)
    for i in range(m):
        cnt += insertion_sort(a, g[i], n)
    print(cnt) shell_sort cnt = 0 cnt 0 g = [] g [] h = 1 h 1 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(*g) print *g g for i in range(m):
        cnt += insertion_sort(a, g[i], n)
     i range(m) range m cnt += insertion_sort(a, g[i], n) cnt insertion_sort(a, g[i], n) insertion_sort a g[i] g i n print(cnt) print cnt a a n n n = int(input()) n int(input()) int input() input int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input a = [int(input()) for _ in range(n)] a [int(input()) for _ in range(n)] shell_sort(a, n) shell_sort a n print('\n'.join(map(str, a))) print '\n'.join(map(str, a)) '\n'.join '\n' join map(str, a) map str a a = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] a def shell_sort(a, n):
    cnt = 0
    g = []
    h = 1
    while h <= n:
        g.append(h)
        h = 3 * h + 1
    g.reverse()
    m = len(g)
    print(m)
    print(*g)
    for i in range(m):
        cnt += insertion_sort(a, g[i], n)
    print(cnt) def shell_sort(a, n):
    cnt = 0
    g = []
    h = 1
    while h <= n:
        g.append(h)
        h = 3 * h + 1
    g.reverse()
    m = len(g)
    print(m)
    print(*g)
    for i in range(m):
        cnt += insertion_sort(a, g[i], n)
    print(cnt) shell_sort n = int(input()) int(input()) n def insertion_sort(a, g, n):
    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 += 1
        a[j + g] = v
    return cnt def insertion_sort(a, g, n):
    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 += 1
        a[j + g] = v
    return cnt insertion_sort
def insertion_sort(a, g, n):
    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 += 1
        a[j + g] = v
    return cnt

def shell_sort(a, n):
    cnt = 0
    g = []
    h = 1
    while h <= n:
        g.append(h)
        h = 3 * h + 1
    g.reverse()
    m = len(g)
    print(m)
    print(*g)
    for i in range(m):
        cnt += insertion_sort(a, g[i], n)
    print(cnt)

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

shell_sort(a, n)
print('\n'.join(map(str, a)))

