def insertion_sort(A, N, gap):
    cnt = 0
    for i in range(gap, N):
        tmp = A[i]
        j = i - gap
        while j>=0 and A[j] > tmp:
            A[j+gap] = A[j]
            j = j - gap
            cnt = cnt + 1
        A[j+gap] = tmp
    return cnt

def shell_sort(A, N):
    cnt = 0
    gaps = [int((3**item-1)/2) for item in range(1, 100) if int((3**item-1)/2) <= N][::-1]
    m = len(gaps)
    for gap in gaps:
        cnt = cnt + insertion_sort(A, N, gap)
    print(m)
    print(' '.join([str(gap) for gap in gaps]))
    print(cnt)
    for i in range(0, N):
        print(A[i])


N = int(input())
A = [int(input()) for i in range(N)]

shell_sort(A, N) def insertion_sort(A, N, gap):
    cnt = 0
    for i in range(gap, N):
        tmp = A[i]
        j = i - gap
        while j>=0 and A[j] > tmp:
            A[j+gap] = A[j]
            j = j - gap
            cnt = cnt + 1
        A[j+gap] = tmp
    return cnt insertion_sort cnt = 0 cnt 0 for i in range(gap, N):
        tmp = A[i]
        j = i - gap
        while j>=0 and A[j] > tmp:
            A[j+gap] = A[j]
            j = j - gap
            cnt = cnt + 1
        A[j+gap] = tmp
     i range(gap, N) range gap N tmp = A[i] tmp A[i] A i j = i - gap j i - gap i gap while j>=0 and A[j] > tmp:
            A[j+gap] = A[j]
            j = j - gap
            cnt = cnt + 1
         j>=0 and A[j] > tmp j>=0 j 0 A[j] > tmp A[j] A j tmp 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 = cnt + 1 cnt cnt + 1 cnt 1 A[j+gap] = tmp A[j+gap] A j+gap j gap tmp return cnt cnt A A N N gap gap def shell_sort(A, N):
    cnt = 0
    gaps = [int((3**item-1)/2) for item in range(1, 100) if int((3**item-1)/2) <= N][::-1]
    m = len(gaps)
    for gap in gaps:
        cnt = cnt + insertion_sort(A, N, gap)
    print(m)
    print(' '.join([str(gap) for gap in gaps]))
    print(cnt)
    for i in range(0, N):
        print(A[i]) shell_sort cnt = 0 cnt 0 int((3**item-1)/2) for item in range(1, 100) if int((3**item-1)/2) <= N for item in range(1, 100) if int((3**item-1)/2) <= N item range(1, 100) range 1 100 int((3**item-1)/2) <= N int((3**item-1)/2) int (3**item-1)/2 3**item-1 3**item 3 item 1 2 N if int((3**item-1)/2) <= N int((3**item-1)/2) int (3**item-1)/2 3**item-1 3**item 3 item 1 2 gaps = [int((3**item-1)/2) for item in range(1, 100) if int((3**item-1)/2) <= N][::-1] gaps [int((3**item-1)/2) for item in range(1, 100) if int((3**item-1)/2) <= N][::-1] [int((3**item-1)/2) for item in range(1, 100) if int((3**item-1)/2) <= N] ::-1 -1 m = len(gaps) m len(gaps) len gaps for gap in gaps:
        cnt = cnt + insertion_sort(A, N, gap)
     gap gaps cnt = cnt + insertion_sort(A, N, gap) cnt cnt + insertion_sort(A, N, gap) cnt insertion_sort(A, N, gap) insertion_sort A N gap print(m) print m str(gap) for gap in gaps for gap in gaps gap gaps for gap in gaps str(gap) str gap print(' '.join([str(gap) for gap in gaps])) print ' '.join([str(gap) for gap in gaps]) ' '.join ' ' join [str(gap) for gap in gaps] print(cnt) print cnt for i in range(0, N):
        print(A[i]) i range(0, N) range 0 N print(A[i]) print A[i] A i A A N N N = int(input()) N int(input()) int input() input int(input()) for i in range(N) for i in range(N) i range(N) range N for i in range(N) int(input()) int input() input A = [int(input()) for i in range(N)] A [int(input()) for i in range(N)] shell_sort(A, N) shell_sort A N N = int(input()) int(input()) N def insertion_sort(A, N, gap):
    cnt = 0
    for i in range(gap, N):
        tmp = A[i]
        j = i - gap
        while j>=0 and A[j] > tmp:
            A[j+gap] = A[j]
            j = j - gap
            cnt = cnt + 1
        A[j+gap] = tmp
    return cnt def insertion_sort(A, N, gap):
    cnt = 0
    for i in range(gap, N):
        tmp = A[i]
        j = i - gap
        while j>=0 and A[j] > tmp:
            A[j+gap] = A[j]
            j = j - gap
            cnt = cnt + 1
        A[j+gap] = tmp
    return cnt insertion_sort A = [int(input()) for i in range(N)] [int(input()) for i in range(N)] A def shell_sort(A, N):
    cnt = 0
    gaps = [int((3**item-1)/2) for item in range(1, 100) if int((3**item-1)/2) <= N][::-1]
    m = len(gaps)
    for gap in gaps:
        cnt = cnt + insertion_sort(A, N, gap)
    print(m)
    print(' '.join([str(gap) for gap in gaps]))
    print(cnt)
    for i in range(0, N):
        print(A[i]) def shell_sort(A, N):
    cnt = 0
    gaps = [int((3**item-1)/2) for item in range(1, 100) if int((3**item-1)/2) <= N][::-1]
    m = len(gaps)
    for gap in gaps:
        cnt = cnt + insertion_sort(A, N, gap)
    print(m)
    print(' '.join([str(gap) for gap in gaps]))
    print(cnt)
    for i in range(0, N):
        print(A[i]) shell_sort
def insertion_sort(A, N, gap):
    cnt = 0
    for i in range(gap, N):
        tmp = A[i]
        j = i - gap
        while j>=0 and A[j] > tmp:
            A[j+gap] = A[j]
            j = j - gap
            cnt = cnt + 1
        A[j+gap] = tmp
    return cnt

def shell_sort(A, N):
    cnt = 0
    gaps = [int((3**item-1)/2) for item in range(1, 100) if int((3**item-1)/2) <= N][::-1]
    m = len(gaps)
    for gap in gaps:
        cnt = cnt + insertion_sort(A, N, gap)
    print(m)
    print(' '.join([str(gap) for gap in gaps]))
    print(cnt)
    for i in range(0, N):
        print(A[i])


N = int(input())
A = [int(input()) for i in range(N)]

shell_sort(A, N)