def calcGaps(n):
    gaps = [1]
    while 3 * gaps[-1] + 1 < n:
        gaps.append(3 * gaps[-1] + 1)
    return gaps[::-1]


def insertionSort(a, n, gap, cnt):
    for i in range(gap, n):
        v = a[i]
        j = i - gap
        while j >= 0 and a[j] > v:
            a[j + gap] = a[j]
            j = j - gap
            cnt += 1
        a[j + gap] = v
    return a, cnt


def shellSort(a, n):
    cnt = 0
    Gaps = calcGaps(n)
    for gap in Gaps:
        a, cnt = insertionSort(a, n, gap, cnt)
    print(len(Gaps))
    print(*Gaps)
    print(cnt)
    print(*a, sep='\n')


n = int(input())
A = [int(input()) for _ in range(n)]

shellSort(A, n) def calcGaps(n):
    gaps = [1]
    while 3 * gaps[-1] + 1 < n:
        gaps.append(3 * gaps[-1] + 1)
    return gaps[::-1] calcGaps gaps = [1] gaps [1] 1 while 3 * gaps[-1] + 1 < n:
        gaps.append(3 * gaps[-1] + 1)
     3 * gaps[-1] + 1 < n 3 * gaps[-1] + 1 3 * gaps[-1] 3 gaps[-1] gaps -1 1 n gaps.append(3 * gaps[-1] + 1) gaps.append gaps append 3 * gaps[-1] + 1 3 * gaps[-1] 3 gaps[-1] gaps -1 1 return gaps[::-1] gaps[::-1] gaps ::-1 -1 n n def insertionSort(a, n, gap, cnt):
    for i in range(gap, n):
        v = a[i]
        j = i - gap
        while j >= 0 and a[j] > v:
            a[j + gap] = a[j]
            j = j - gap
            cnt += 1
        a[j + gap] = v
    return a, cnt insertionSort for i in range(gap, n):
        v = a[i]
        j = i - gap
        while j >= 0 and a[j] > v:
            a[j + gap] = a[j]
            j = j - gap
            cnt += 1
        a[j + gap] = v
     i range(gap, n) range gap n v = a[i] v a[i] a i j = i - gap j i - gap i gap while j >= 0 and a[j] > v:
            a[j + gap] = a[j]
            j = j - gap
            cnt += 1
         j >= 0 and a[j] > v j >= 0 j 0 a[j] > v a[j] a j v a[j + gap] = a[j] a[j + gap] a j + gap j gap a[j] a j j = j - gap j j - gap j gap cnt += 1 cnt 1 a[j + gap] = v a[j + gap] a j + gap j gap v return a, cnt return a, cnt a cnt a a n n gap gap cnt cnt def shellSort(a, n):
    cnt = 0
    Gaps = calcGaps(n)
    for gap in Gaps:
        a, cnt = insertionSort(a, n, gap, cnt)
    print(len(Gaps))
    print(*Gaps)
    print(cnt)
    print(*a, sep='\n') shellSort cnt = 0 cnt 0 Gaps = calcGaps(n) Gaps calcGaps(n) calcGaps n for gap in Gaps:
        a, cnt = insertionSort(a, n, gap, cnt)
     gap Gaps a, cnt = insertionSort(a, n, gap, cnt) a insertionSort(a, n, gap, cnt) insertionSort a n gap cnt cnt print(len(Gaps)) print len(Gaps) len Gaps print(*Gaps) print *Gaps Gaps print(cnt) print cnt print(*a, sep='\n') print *a a sep='\n' sep '\n' a a n n 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 A = [int(input()) for _ in range(n)] A [int(input()) for _ in range(n)] shellSort(A, n) shellSort A n def shellSort(a, n):
    cnt = 0
    Gaps = calcGaps(n)
    for gap in Gaps:
        a, cnt = insertionSort(a, n, gap, cnt)
    print(len(Gaps))
    print(*Gaps)
    print(cnt)
    print(*a, sep='\n') def shellSort(a, n):
    cnt = 0
    Gaps = calcGaps(n)
    for gap in Gaps:
        a, cnt = insertionSort(a, n, gap, cnt)
    print(len(Gaps))
    print(*Gaps)
    print(cnt)
    print(*a, sep='\n') shellSort n = int(input()) int(input()) n def calcGaps(n):
    gaps = [1]
    while 3 * gaps[-1] + 1 < n:
        gaps.append(3 * gaps[-1] + 1)
    return gaps[::-1] def calcGaps(n):
    gaps = [1]
    while 3 * gaps[-1] + 1 < n:
        gaps.append(3 * gaps[-1] + 1)
    return gaps[::-1] calcGaps def insertionSort(a, n, gap, cnt):
    for i in range(gap, n):
        v = a[i]
        j = i - gap
        while j >= 0 and a[j] > v:
            a[j + gap] = a[j]
            j = j - gap
            cnt += 1
        a[j + gap] = v
    return a, cnt def insertionSort(a, n, gap, cnt):
    for i in range(gap, n):
        v = a[i]
        j = i - gap
        while j >= 0 and a[j] > v:
            a[j + gap] = a[j]
            j = j - gap
            cnt += 1
        a[j + gap] = v
    return a, cnt insertionSort A = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] A
def calcGaps(n):
    gaps = [1]
    while 3 * gaps[-1] + 1 < n:
        gaps.append(3 * gaps[-1] + 1)
    return gaps[::-1]


def insertionSort(a, n, gap, cnt):
    for i in range(gap, n):
        v = a[i]
        j = i - gap
        while j >= 0 and a[j] > v:
            a[j + gap] = a[j]
            j = j - gap
            cnt += 1
        a[j + gap] = v
    return a, cnt


def shellSort(a, n):
    cnt = 0
    Gaps = calcGaps(n)
    for gap in Gaps:
        a, cnt = insertionSort(a, n, gap, cnt)
    print(len(Gaps))
    print(*Gaps)
    print(cnt)
    print(*a, sep='\n')


n = int(input())
A = [int(input()) for _ in range(n)]

shellSort(A, n)
