N = int(input())
A = list(int(input()) for _ in range(N))


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


def shell_sort(a, n):
    cnt = 0
    *g, = []
    h = 0
    for i in range(0, n):
        h = h * 3 + 1
        if h > n:
            break
        g.insert(0, h)

    m = len(g)
    for i in range(0, m):
        cnt += ins_sort(a, n, g[i])
    print(m)
    print(*g)
    print(cnt)
    for i in range(len(a)):
        print(a[i])


shell_sort(A, N)
 N = int(input()) N int(input()) int input() input A = list(int(input()) for _ in range(N)) A list(int(input()) for _ in range(N)) list int(input()) int input() input def ins_sort(a, n, g):
    count = 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 -= g
            count += 1
        a[j+g] = v
    return count ins_sort count = 0 count 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 -= g
            count += 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 -= g
            count += 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 -= g j g count += 1 count 1 a[j+g] = v a[j+g] a j+g j g v return count count a a n n g g def shell_sort(a, n):
    cnt = 0
    *g, = []
    h = 0
    for i in range(0, n):
        h = h * 3 + 1
        if h > n:
            break
        g.insert(0, h)

    m = len(g)
    for i in range(0, m):
        cnt += ins_sort(a, n, g[i])
    print(m)
    print(*g)
    print(cnt)
    for i in range(len(a)):
        print(a[i]) shell_sort cnt = 0 cnt 0 *g, = [] *g g [] h = 0 h 0 for i in range(0, n):
        h = h * 3 + 1
        if h > n:
            break
        g.insert(0, h)

     i range(0, n) range 0 n h = h * 3 + 1 h h * 3 + 1 h * 3 h 3 1 if h > n:
            break
         h > n h n break g.insert(0, h) g.insert g insert 0 h m = len(g) m len(g) len g for i in range(0, m):
        cnt += ins_sort(a, n, g[i])
     i range(0, m) range 0 m cnt += ins_sort(a, n, g[i]) cnt ins_sort(a, n, g[i]) ins_sort a n g[i] g i print(m) print m print(*g) print *g g print(cnt) print cnt for i in range(len(a)):
        print(a[i]) i range(len(a)) range len(a) len a print(a[i]) print a[i] a i a a n n shell_sort(A, N) shell_sort A N A = list(int(input()) for _ in range(N)) list(int(input()) for _ in range(N)) A def ins_sort(a, n, g):
    count = 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 -= g
            count += 1
        a[j+g] = v
    return count def ins_sort(a, n, g):
    count = 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 -= g
            count += 1
        a[j+g] = v
    return count ins_sort N = int(input()) int(input()) N def shell_sort(a, n):
    cnt = 0
    *g, = []
    h = 0
    for i in range(0, n):
        h = h * 3 + 1
        if h > n:
            break
        g.insert(0, h)

    m = len(g)
    for i in range(0, m):
        cnt += ins_sort(a, n, g[i])
    print(m)
    print(*g)
    print(cnt)
    for i in range(len(a)):
        print(a[i]) def shell_sort(a, n):
    cnt = 0
    *g, = []
    h = 0
    for i in range(0, n):
        h = h * 3 + 1
        if h > n:
            break
        g.insert(0, h)

    m = len(g)
    for i in range(0, m):
        cnt += ins_sort(a, n, g[i])
    print(m)
    print(*g)
    print(cnt)
    for i in range(len(a)):
        print(a[i]) shell_sort
N = int(input())
A = list(int(input()) for _ in range(N))


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


def shell_sort(a, n):
    cnt = 0
    *g, = []
    h = 0
    for i in range(0, n):
        h = h * 3 + 1
        if h > n:
            break
        g.insert(0, h)

    m = len(g)
    for i in range(0, m):
        cnt += ins_sort(a, n, g[i])
    print(m)
    print(*g)
    print(cnt)
    for i in range(len(a)):
        print(a[i])


shell_sort(A, N)

