def insertionSort(A, n, g, cnt):
    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

    return cnt


def shellSort(A, n):
    cnt = 0
    m = 1
    gs = [1]
    gn = 1
    while (3*gn+1) <= n:
        gn = 3*gn + 1
        gs.append(gn)
        m += 1
    gs = gs[::-1]
    print(m)
    for g in gs:
        if g == 1:
            print(g)
        else:
            print('{} '.format(g), end='')
        cnt = insertionSort(A, n, g, cnt)
    print(cnt)

n = int(input())
A = [int(input()) for _ in range(n)]
shellSort(A, n)
[print(a) for a in A] def insertionSort(A, n, g, cnt):
    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

    return cnt insertionSort 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 return cnt cnt A A n n g g cnt cnt def shellSort(A, n):
    cnt = 0
    m = 1
    gs = [1]
    gn = 1
    while (3*gn+1) <= n:
        gn = 3*gn + 1
        gs.append(gn)
        m += 1
    gs = gs[::-1]
    print(m)
    for g in gs:
        if g == 1:
            print(g)
        else:
            print('{} '.format(g), end='')
        cnt = insertionSort(A, n, g, cnt)
    print(cnt) shellSort cnt = 0 cnt 0 m = 1 m 1 gs = [1] gs [1] 1 gn = 1 gn 1 while (3*gn+1) <= n:
        gn = 3*gn + 1
        gs.append(gn)
        m += 1
     (3*gn+1) <= n 3*gn+1 3*gn 3 gn 1 n gn = 3*gn + 1 gn 3*gn + 1 3*gn 3 gn 1 gs.append(gn) gs.append gs append gn m += 1 m 1 gs = gs[::-1] gs gs[::-1] gs ::-1 -1 print(m) print m for g in gs:
        if g == 1:
            print(g)
        else:
            print('{} '.format(g), end='')
        cnt = insertionSort(A, n, g, cnt)
     g gs if g == 1:
            print(g)
        else:
            print('{} '.format(g), end='')
         g == 1 g 1 print(g) print g print('{} '.format(g), end='') print '{} '.format(g) '{} '.format '{} ' format g end='' end '' cnt = insertionSort(A, n, g, cnt) cnt insertionSort(A, n, g, cnt) insertionSort A n g cnt print(cnt) print cnt 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 print(a) for a in A for a in A a A for a in A print(a) print a [print(a) for a in A] def insertionSort(A, n, g, cnt):
    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

    return cnt def insertionSort(A, n, g, cnt):
    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

    return cnt insertionSort def shellSort(A, n):
    cnt = 0
    m = 1
    gs = [1]
    gn = 1
    while (3*gn+1) <= n:
        gn = 3*gn + 1
        gs.append(gn)
        m += 1
    gs = gs[::-1]
    print(m)
    for g in gs:
        if g == 1:
            print(g)
        else:
            print('{} '.format(g), end='')
        cnt = insertionSort(A, n, g, cnt)
    print(cnt) def shellSort(A, n):
    cnt = 0
    m = 1
    gs = [1]
    gn = 1
    while (3*gn+1) <= n:
        gn = 3*gn + 1
        gs.append(gn)
        m += 1
    gs = gs[::-1]
    print(m)
    for g in gs:
        if g == 1:
            print(g)
        else:
            print('{} '.format(g), end='')
        cnt = insertionSort(A, n, g, cnt)
    print(cnt) shellSort A = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] A n = int(input()) int(input()) n
def insertionSort(A, n, g, cnt):
    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

    return cnt


def shellSort(A, n):
    cnt = 0
    m = 1
    gs = [1]
    gn = 1
    while (3*gn+1) <= n:
        gn = 3*gn + 1
        gs.append(gn)
        m += 1
    gs = gs[::-1]
    print(m)
    for g in gs:
        if g == 1:
            print(g)
        else:
            print('{} '.format(g), end='')
        cnt = insertionSort(A, n, g, cnt)
    print(cnt)

n = int(input())
A = [int(input()) for _ in range(n)]
shellSort(A, n)
[print(a) for a in A]
