import math
def print_list(a):
    out = ''
    for ai in a:
        out += str(ai) + ' '
    else:
        out = out[:-1]
    print(out)

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

def shell_sort(a, n):
    cnt = 0
    m = 0
    g = []
    h = 1
    while True:
        if h > n:
            break
        m += 1
        g.append(h)
        h = 3 * h + 1
    g.reverse()

    for i in range(m):
        cnt += insertion_sort(a, n, g[i])
    print(m)
    print_list(g)
    print(cnt)
    for i in a:
        print(i)

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

shell_sort(a, n)
 import math math def print_list(a):
    out = ''
    for ai in a:
        out += str(ai) + ' '
    else:
        out = out[:-1]
    print(out) print_list out = '' out '' for ai in a:
        out += str(ai) + ' '
    else:
        out = out[:-1]
     ai a out += str(ai) + ' ' out str(ai) + ' ' str(ai) str ai ' ' out = out[:-1] out out[:-1] out :-1 -1 print(out) print out a a def insertion_sort(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 += 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 n n g g def shell_sort(a, n):
    cnt = 0
    m = 0
    g = []
    h = 1
    while True:
        if h > n:
            break
        m += 1
        g.append(h)
        h = 3 * h + 1
    g.reverse()

    for i in range(m):
        cnt += insertion_sort(a, n, g[i])
    print(m)
    print_list(g)
    print(cnt)
    for i in a:
        print(i) shell_sort cnt = 0 cnt 0 m = 0 m 0 g = [] g [] h = 1 h 1 while True:
        if h > n:
            break
        m += 1
        g.append(h)
        h = 3 * h + 1
     True if h > n:
            break
         h > n h n break m += 1 m 1 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 for i in range(m):
        cnt += insertion_sort(a, n, g[i])
     i range(m) range m cnt += insertion_sort(a, n, g[i]) cnt insertion_sort(a, n, g[i]) insertion_sort a n g[i] g i print(m) print m print_list(g) print_list g print(cnt) print cnt for i in a:
        print(i) i a print(i) print i a a n n n = int(input()) n int(input()) int input() input a = [0] * n a [0] * n [0] 0 n for i in range(n):
    a[i] = int(input()) i range(n) range n a[i] = int(input()) a[i] a i int(input()) int input() input shell_sort(a, n) shell_sort a n n = int(input()) int(input()) n a = [0] * n [0] * n a def insertion_sort(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 += 1
        a[j + g] = v
    return cnt def insertion_sort(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 += 1
        a[j + g] = v
    return cnt insertion_sort def print_list(a):
    out = ''
    for ai in a:
        out += str(ai) + ' '
    else:
        out = out[:-1]
    print(out) def print_list(a):
    out = ''
    for ai in a:
        out += str(ai) + ' '
    else:
        out = out[:-1]
    print(out) print_list def shell_sort(a, n):
    cnt = 0
    m = 0
    g = []
    h = 1
    while True:
        if h > n:
            break
        m += 1
        g.append(h)
        h = 3 * h + 1
    g.reverse()

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

    for i in range(m):
        cnt += insertion_sort(a, n, g[i])
    print(m)
    print_list(g)
    print(cnt)
    for i in a:
        print(i) shell_sort
import math
def print_list(a):
    out = ''
    for ai in a:
        out += str(ai) + ' '
    else:
        out = out[:-1]
    print(out)

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

def shell_sort(a, n):
    cnt = 0
    m = 0
    g = []
    h = 1
    while True:
        if h > n:
            break
        m += 1
        g.append(h)
        h = 3 * h + 1
    g.reverse()

    for i in range(m):
        cnt += insertion_sort(a, n, g[i])
    print(m)
    print_list(g)
    print(cnt)
    for i in a:
        print(i)

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

shell_sort(a, n)

