# シェルソート
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_D&lang=jp
# 挿入ソートを応用してn個の整数を含む数列Aを昇順に整列するプログラム

def show(array):
    for i in range(len(array)):
        if (i+1) >= len(array):
            print(array[i])
        else:
            print(array[i], end=' ')

def insertion_sort(c, g):
    n = len(c)
    count = 0
    for i in range(g, n):
        v = c[i]
        j = i - g
        while j >= 0 and c[j] > v:
            c[j+g] = c[j]
            j = j - g
            count += 1
        c[j+g] = v
    return c, count


def shell_sort(c, G):
    counts = 0
    for g in G:
        co, count = insertion_sort(c, g)
        counts += count
    return co, counts


def main():
    n = int(input())
    c = [int(input()) for _ in range(n)]

    # For making G
    n = len(c)
    g = []
    for m in range(1, 100):
        t = (3 ** m - 1) // 2
        if t > n:
            break
        g.append(t)
    g = g[::-1]

    result, count = shell_sort(c, g)

    print(m-1)
    show(g)
    print(count)
    for num in result:
        print(num)

main() def show(array):
    for i in range(len(array)):
        if (i+1) >= len(array):
            print(array[i])
        else:
            print(array[i], end=' ') show for i in range(len(array)):
        if (i+1) >= len(array):
            print(array[i])
        else:
            print(array[i], end=' ') i range(len(array)) range len(array) len array if (i+1) >= len(array):
            print(array[i])
        else:
            print(array[i], end=' ') (i+1) >= len(array) i+1 i 1 len(array) len array print(array[i]) print array[i] array i print(array[i], end=' ') print array[i] array i end=' ' end ' ' array array def insertion_sort(c, g):
    n = len(c)
    count = 0
    for i in range(g, n):
        v = c[i]
        j = i - g
        while j >= 0 and c[j] > v:
            c[j+g] = c[j]
            j = j - g
            count += 1
        c[j+g] = v
    return c, count insertion_sort n = len(c) n len(c) len c count = 0 count 0 for i in range(g, n):
        v = c[i]
        j = i - g
        while j >= 0 and c[j] > v:
            c[j+g] = c[j]
            j = j - g
            count += 1
        c[j+g] = v
     i range(g, n) range g n v = c[i] v c[i] c i j = i - g j i - g i g while j >= 0 and c[j] > v:
            c[j+g] = c[j]
            j = j - g
            count += 1
         j >= 0 and c[j] > v j >= 0 j 0 c[j] > v c[j] c j v c[j+g] = c[j] c[j+g] c j+g j g c[j] c j j = j - g j j - g j g count += 1 count 1 c[j+g] = v c[j+g] c j+g j g v return c, count return c, count c count c c g g def shell_sort(c, G):
    counts = 0
    for g in G:
        co, count = insertion_sort(c, g)
        counts += count
    return co, counts shell_sort counts = 0 counts 0 for g in G:
        co, count = insertion_sort(c, g)
        counts += count
     g G co, count = insertion_sort(c, g) co insertion_sort(c, g) insertion_sort c g count counts += count counts count return co, counts return co, counts co counts c c G G def main():
    n = int(input())
    c = [int(input()) for _ in range(n)]

    # For making G
    n = len(c)
    g = []
    for m in range(1, 100):
        t = (3 ** m - 1) // 2
        if t > n:
            break
        g.append(t)
    g = g[::-1]

    result, count = shell_sort(c, g)

    print(m-1)
    show(g)
    print(count)
    for num in result:
        print(num) main 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 c = [int(input()) for _ in range(n)] c [int(input()) for _ in range(n)] n = len(c) n len(c) len c g = [] g [] for m in range(1, 100):
        t = (3 ** m - 1) // 2
        if t > n:
            break
        g.append(t)
     m range(1, 100) range 1 100 t = (3 ** m - 1) // 2 t (3 ** m - 1) // 2 3 ** m - 1 3 ** m 3 m 1 2 if t > n:
            break
         t > n t n break g.append(t) g.append g append t g = g[::-1] g g[::-1] g ::-1 -1 result, count = shell_sort(c, g) result shell_sort(c, g) shell_sort c g count print(m-1) print m-1 m 1 show(g) show g print(count) print count for num in result:
        print(num) num result print(num) print num main() main def shell_sort(c, G):
    counts = 0
    for g in G:
        co, count = insertion_sort(c, g)
        counts += count
    return co, counts def shell_sort(c, G):
    counts = 0
    for g in G:
        co, count = insertion_sort(c, g)
        counts += count
    return co, counts shell_sort def main():
    n = int(input())
    c = [int(input()) for _ in range(n)]

    # For making G
    n = len(c)
    g = []
    for m in range(1, 100):
        t = (3 ** m - 1) // 2
        if t > n:
            break
        g.append(t)
    g = g[::-1]

    result, count = shell_sort(c, g)

    print(m-1)
    show(g)
    print(count)
    for num in result:
        print(num) def main():
    n = int(input())
    c = [int(input()) for _ in range(n)]

    # For making G
    n = len(c)
    g = []
    for m in range(1, 100):
        t = (3 ** m - 1) // 2
        if t > n:
            break
        g.append(t)
    g = g[::-1]

    result, count = shell_sort(c, g)

    print(m-1)
    show(g)
    print(count)
    for num in result:
        print(num) main def insertion_sort(c, g):
    n = len(c)
    count = 0
    for i in range(g, n):
        v = c[i]
        j = i - g
        while j >= 0 and c[j] > v:
            c[j+g] = c[j]
            j = j - g
            count += 1
        c[j+g] = v
    return c, count def insertion_sort(c, g):
    n = len(c)
    count = 0
    for i in range(g, n):
        v = c[i]
        j = i - g
        while j >= 0 and c[j] > v:
            c[j+g] = c[j]
            j = j - g
            count += 1
        c[j+g] = v
    return c, count insertion_sort def show(array):
    for i in range(len(array)):
        if (i+1) >= len(array):
            print(array[i])
        else:
            print(array[i], end=' ') def show(array):
    for i in range(len(array)):
        if (i+1) >= len(array):
            print(array[i])
        else:
            print(array[i], end=' ') show
# シェルソート
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_D&lang=jp
# 挿入ソートを応用してn個の整数を含む数列Aを昇順に整列するプログラム

def show(array):
    for i in range(len(array)):
        if (i+1) >= len(array):
            print(array[i])
        else:
            print(array[i], end=' ')

def insertion_sort(c, g):
    n = len(c)
    count = 0
    for i in range(g, n):
        v = c[i]
        j = i - g
        while j >= 0 and c[j] > v:
            c[j+g] = c[j]
            j = j - g
            count += 1
        c[j+g] = v
    return c, count


def shell_sort(c, G):
    counts = 0
    for g in G:
        co, count = insertion_sort(c, g)
        counts += count
    return co, counts


def main():
    n = int(input())
    c = [int(input()) for _ in range(n)]

    # For making G
    n = len(c)
    g = []
    for m in range(1, 100):
        t = (3 ** m - 1) // 2
        if t > n:
            break
        g.append(t)
    g = g[::-1]

    result, count = shell_sort(c, g)

    print(m-1)
    show(g)
    print(count)
    for num in result:
        print(num)

main()
