def shellsort(a):
    l = len(a)
    gaps = [1]
    while gaps[0]*3+1 < l and len(gaps) <= 100:
        gaps.insert(0, gaps[0]*3+1)
    count = 0
    for g in gaps:
        for i in range(g, l):
            v = a[i]
            j = i-g
            while j >= 0 and v < a[j]:
                a[j+g] = a[j]
                j -= g
                count += 1
            a[j+g] = v

    print(len(gaps))
    print(" ".join([str(n) for n in gaps]))
    print(count)
    print("\n".join([str(n) for n in a]))

shellsort([int(input()) for _ in [None]*(int(input()))]) def shellsort(a):
    l = len(a)
    gaps = [1]
    while gaps[0]*3+1 < l and len(gaps) <= 100:
        gaps.insert(0, gaps[0]*3+1)
    count = 0
    for g in gaps:
        for i in range(g, l):
            v = a[i]
            j = i-g
            while j >= 0 and v < a[j]:
                a[j+g] = a[j]
                j -= g
                count += 1
            a[j+g] = v

    print(len(gaps))
    print(" ".join([str(n) for n in gaps]))
    print(count)
    print("\n".join([str(n) for n in a])) shellsort l = len(a) l len(a) len a gaps = [1] gaps [1] 1 while gaps[0]*3+1 < l and len(gaps) <= 100:
        gaps.insert(0, gaps[0]*3+1)
     gaps[0]*3+1 < l and len(gaps) <= 100 gaps[0]*3+1 < l gaps[0]*3+1 gaps[0]*3 gaps[0] gaps 0 3 1 l len(gaps) <= 100 len(gaps) len gaps 100 gaps.insert(0, gaps[0]*3+1) gaps.insert gaps insert 0 gaps[0]*3+1 gaps[0]*3 gaps[0] gaps 0 3 1 count = 0 count 0 for g in gaps:
        for i in range(g, l):
            v = a[i]
            j = i-g
            while j >= 0 and v < a[j]:
                a[j+g] = a[j]
                j -= g
                count += 1
            a[j+g] = v

     g gaps for i in range(g, l):
            v = a[i]
            j = i-g
            while j >= 0 and v < a[j]:
                a[j+g] = a[j]
                j -= g
                count += 1
            a[j+g] = v

     i range(g, l) range g l v = a[i] v a[i] a i j = i-g j i-g i g while j >= 0 and v < a[j]:
                a[j+g] = a[j]
                j -= g
                count += 1
             j >= 0 and v < a[j] j >= 0 j 0 v < a[j] v a[j] a j 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 print(len(gaps)) print len(gaps) len gaps str(n) for n in gaps for n in gaps n gaps for n in gaps str(n) str n print(" ".join([str(n) for n in gaps])) print " ".join([str(n) for n in gaps]) " ".join " " join [str(n) for n in gaps] print(count) print count str(n) for n in a for n in a n a for n in a str(n) str n print("\n".join([str(n) for n in a])) print "\n".join([str(n) for n in a]) "\n".join "\n" join [str(n) for n in a] a a int(input()) for _ in [None]*(int(input())) for _ in [None]*(int(input())) _ [None]*(int(input())) [None] None int(input()) int input() input for _ in [None]*(int(input())) int(input()) int input() input shellsort([int(input()) for _ in [None]*(int(input()))]) shellsort [int(input()) for _ in [None]*(int(input()))] def shellsort(a):
    l = len(a)
    gaps = [1]
    while gaps[0]*3+1 < l and len(gaps) <= 100:
        gaps.insert(0, gaps[0]*3+1)
    count = 0
    for g in gaps:
        for i in range(g, l):
            v = a[i]
            j = i-g
            while j >= 0 and v < a[j]:
                a[j+g] = a[j]
                j -= g
                count += 1
            a[j+g] = v

    print(len(gaps))
    print(" ".join([str(n) for n in gaps]))
    print(count)
    print("\n".join([str(n) for n in a])) def shellsort(a):
    l = len(a)
    gaps = [1]
    while gaps[0]*3+1 < l and len(gaps) <= 100:
        gaps.insert(0, gaps[0]*3+1)
    count = 0
    for g in gaps:
        for i in range(g, l):
            v = a[i]
            j = i-g
            while j >= 0 and v < a[j]:
                a[j+g] = a[j]
                j -= g
                count += 1
            a[j+g] = v

    print(len(gaps))
    print(" ".join([str(n) for n in gaps]))
    print(count)
    print("\n".join([str(n) for n in a])) shellsort
def shellsort(a):
    l = len(a)
    gaps = [1]
    while gaps[0]*3+1 < l and len(gaps) <= 100:
        gaps.insert(0, gaps[0]*3+1)
    count = 0
    for g in gaps:
        for i in range(g, l):
            v = a[i]
            j = i-g
            while j >= 0 and v < a[j]:
                a[j+g] = a[j]
                j -= g
                count += 1
            a[j+g] = v

    print(len(gaps))
    print(" ".join([str(n) for n in gaps]))
    print(count)
    print("\n".join([str(n) for n in a]))

shellsort([int(input()) for _ in [None]*(int(input()))])