import sys

input = sys.stdin.readline


def main():
    n = int(input())
    A = [None] * n
    for i in range(n):
        A[i] = int(input())

    G = []
    g = 1
    while True:
        G.append(g)
        g = 3 * g + 1
        if g >= n:
            break
    G = G[::-1]
    m = len(G)
    cnt = 0

    for g in G:
        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
                cnt += 1
            A[j + g] = v

    print(m)
    print(" ".join(map(str, G)))
    print(cnt)
    print("\n".join(map(str, A)))


if __name__ == "__main__":
    main()
 import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    n = int(input())
    A = [None] * n
    for i in range(n):
        A[i] = int(input())

    G = []
    g = 1
    while True:
        G.append(g)
        g = 3 * g + 1
        if g >= n:
            break
    G = G[::-1]
    m = len(G)
    cnt = 0

    for g in G:
        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
                cnt += 1
            A[j + g] = v

    print(m)
    print(" ".join(map(str, G)))
    print(cnt)
    print("\n".join(map(str, A))) main n = int(input()) n int(input()) int input() input A = [None] * n A [None] * n [None] None 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 G = [] G [] g = 1 g 1 while True:
        G.append(g)
        g = 3 * g + 1
        if g >= n:
            break
     True G.append(g) G.append G append g g = 3 * g + 1 g 3 * g + 1 3 * g 3 g 1 if g >= n:
            break
     g >= n g n break G = G[::-1] G G[::-1] G ::-1 -1 m = len(G) m len(G) len G cnt = 0 cnt 0 for g in G:
        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
                cnt += 1
            A[j + g] = v

     g G 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
                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 -= 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 -= g j g cnt += 1 cnt 1 A[j + g] = v A[j + g] A j + g j g v print(m) print m print(" ".join(map(str, G))) print " ".join(map(str, G)) " ".join " " join map(str, G) map str G print(cnt) print cnt print("\n".join(map(str, A))) print "\n".join(map(str, A)) "\n".join "\n" join map(str, A) map str A if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n = int(input())
    A = [None] * n
    for i in range(n):
        A[i] = int(input())

    G = []
    g = 1
    while True:
        G.append(g)
        g = 3 * g + 1
        if g >= n:
            break
    G = G[::-1]
    m = len(G)
    cnt = 0

    for g in G:
        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
                cnt += 1
            A[j + g] = v

    print(m)
    print(" ".join(map(str, G)))
    print(cnt)
    print("\n".join(map(str, A))) def main():
    n = int(input())
    A = [None] * n
    for i in range(n):
        A[i] = int(input())

    G = []
    g = 1
    while True:
        G.append(g)
        g = 3 * g + 1
        if g >= n:
            break
    G = G[::-1]
    m = len(G)
    cnt = 0

    for g in G:
        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
                cnt += 1
            A[j + g] = v

    print(m)
    print(" ".join(map(str, G)))
    print(cnt)
    print("\n".join(map(str, A))) main input = sys.stdin.readline sys.stdin.readline input
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    A = [None] * n
    for i in range(n):
        A[i] = int(input())

    G = []
    g = 1
    while True:
        G.append(g)
        g = 3 * g + 1
        if g >= n:
            break
    G = G[::-1]
    m = len(G)
    cnt = 0

    for g in G:
        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
                cnt += 1
            A[j + g] = v

    print(m)
    print(" ".join(map(str, G)))
    print(cnt)
    print("\n".join(map(str, A)))


if __name__ == "__main__":
    main()

