#!/usr/bin/env python3

def construct_gs(n):
    gs = []
    g = 1
    while g <= n:
        gs.append(g)
        g = 3 * g + 1
    return gs[::-1]


def shell_sort(xs, n):
    global cnt
    cnt = 0
    gs = construct_gs(n)
    m = len(gs)
    def insertion_sort(g):
        global cnt
        for i in range(g, n):
            v = xs[i]
            j = i - g
            while j >= 0 and xs[j] > v:
                xs[j + g] = xs[j]
                j = j - g
                cnt += 1
            xs[j + g] = v
    for g in gs:
        insertion_sort(g)
    return m, gs, cnt, xs


def main():
    n = int(input())
    xs = [int(input()) for _ in range(n)]
    m, gs, cnt, xs = shell_sort(xs, n)
    print(m)
    print(" ".join(map(str, gs)))
    print(cnt)
    for x in xs:
        print(x)


if __name__ == '__main__':
    main() def construct_gs(n):
    gs = []
    g = 1
    while g <= n:
        gs.append(g)
        g = 3 * g + 1
    return gs[::-1] construct_gs gs = [] gs [] g = 1 g 1 while g <= n:
        gs.append(g)
        g = 3 * g + 1
     g <= n g n gs.append(g) gs.append gs append g g = 3 * g + 1 g 3 * g + 1 3 * g 3 g 1 return gs[::-1] gs[::-1] gs ::-1 -1 n n def shell_sort(xs, n):
    global cnt
    cnt = 0
    gs = construct_gs(n)
    m = len(gs)
    def insertion_sort(g):
        global cnt
        for i in range(g, n):
            v = xs[i]
            j = i - g
            while j >= 0 and xs[j] > v:
                xs[j + g] = xs[j]
                j = j - g
                cnt += 1
            xs[j + g] = v
    for g in gs:
        insertion_sort(g)
    return m, gs, cnt, xs shell_sort global cnt cnt = 0 cnt 0 gs = construct_gs(n) gs construct_gs(n) construct_gs n m = len(gs) m len(gs) len gs def insertion_sort(g):
        global cnt
        for i in range(g, n):
            v = xs[i]
            j = i - g
            while j >= 0 and xs[j] > v:
                xs[j + g] = xs[j]
                j = j - g
                cnt += 1
            xs[j + g] = v
     insertion_sort global cnt for i in range(g, n):
            v = xs[i]
            j = i - g
            while j >= 0 and xs[j] > v:
                xs[j + g] = xs[j]
                j = j - g
                cnt += 1
            xs[j + g] = v
     i range(g, n) range g n v = xs[i] v xs[i] xs i j = i - g j i - g i g while j >= 0 and xs[j] > v:
                xs[j + g] = xs[j]
                j = j - g
                cnt += 1
             j >= 0 and xs[j] > v j >= 0 j 0 xs[j] > v xs[j] xs j v xs[j + g] = xs[j] xs[j + g] xs j + g j g xs[j] xs j j = j - g j j - g j g cnt += 1 cnt 1 xs[j + g] = v xs[j + g] xs j + g j g v g g for g in gs:
        insertion_sort(g)
     g gs insertion_sort(g) insertion_sort g return m, gs, cnt, xs return m, gs, cnt, xs m gs cnt xs xs xs n n def main():
    n = int(input())
    xs = [int(input()) for _ in range(n)]
    m, gs, cnt, xs = shell_sort(xs, n)
    print(m)
    print(" ".join(map(str, gs)))
    print(cnt)
    for x in xs:
        print(x) 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 xs = [int(input()) for _ in range(n)] xs [int(input()) for _ in range(n)] m, gs, cnt, xs = shell_sort(xs, n) m shell_sort(xs, n) shell_sort xs n gs cnt xs print(m) print m print(" ".join(map(str, gs))) print " ".join(map(str, gs)) " ".join " " join map(str, gs) map str gs print(cnt) print cnt for x in xs:
        print(x) x xs print(x) print x if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def construct_gs(n):
    gs = []
    g = 1
    while g <= n:
        gs.append(g)
        g = 3 * g + 1
    return gs[::-1] def construct_gs(n):
    gs = []
    g = 1
    while g <= n:
        gs.append(g)
        g = 3 * g + 1
    return gs[::-1] construct_gs def shell_sort(xs, n):
    global cnt
    cnt = 0
    gs = construct_gs(n)
    m = len(gs)
    def insertion_sort(g):
        global cnt
        for i in range(g, n):
            v = xs[i]
            j = i - g
            while j >= 0 and xs[j] > v:
                xs[j + g] = xs[j]
                j = j - g
                cnt += 1
            xs[j + g] = v
    for g in gs:
        insertion_sort(g)
    return m, gs, cnt, xs def shell_sort(xs, n):
    global cnt
    cnt = 0
    gs = construct_gs(n)
    m = len(gs)
    def insertion_sort(g):
        global cnt
        for i in range(g, n):
            v = xs[i]
            j = i - g
            while j >= 0 and xs[j] > v:
                xs[j + g] = xs[j]
                j = j - g
                cnt += 1
            xs[j + g] = v
    for g in gs:
        insertion_sort(g)
    return m, gs, cnt, xs shell_sort def main():
    n = int(input())
    xs = [int(input()) for _ in range(n)]
    m, gs, cnt, xs = shell_sort(xs, n)
    print(m)
    print(" ".join(map(str, gs)))
    print(cnt)
    for x in xs:
        print(x) def main():
    n = int(input())
    xs = [int(input()) for _ in range(n)]
    m, gs, cnt, xs = shell_sort(xs, n)
    print(m)
    print(" ".join(map(str, gs)))
    print(cnt)
    for x in xs:
        print(x) main
#!/usr/bin/env python3

def construct_gs(n):
    gs = []
    g = 1
    while g <= n:
        gs.append(g)
        g = 3 * g + 1
    return gs[::-1]


def shell_sort(xs, n):
    global cnt
    cnt = 0
    gs = construct_gs(n)
    m = len(gs)
    def insertion_sort(g):
        global cnt
        for i in range(g, n):
            v = xs[i]
            j = i - g
            while j >= 0 and xs[j] > v:
                xs[j + g] = xs[j]
                j = j - g
                cnt += 1
            xs[j + g] = v
    for g in gs:
        insertion_sort(g)
    return m, gs, cnt, xs


def main():
    n = int(input())
    xs = [int(input()) for _ in range(n)]
    m, gs, cnt, xs = shell_sort(xs, n)
    print(m)
    print(" ".join(map(str, gs)))
    print(cnt)
    for x in xs:
        print(x)


if __name__ == '__main__':
    main()