def insertionSort(A, n, g):
    cnt = 0
    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 = j - g
            cnt += 1
        A[j+g] = v
    return cnt


def shellSort(A, n):
    G = []
    h = 1
    while True:
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1

    cnt = 0
    print(len(G))
    G = list(reversed(G))
    for g in G:
        cnt += insertionSort(A, n, g)

    print(*G)
    print(cnt)
    print('\n'.join(map(str, A)))


arr_length = int(input())
arr_num = []
for i in range(arr_length):
    arr_num.append(int(input()))

shellSort(arr_num, arr_length) def insertionSort(A, n, g):
    cnt = 0
    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 = j - g
            cnt += 1
        A[j+g] = v
    return cnt insertionSort cnt = 0 cnt 0 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 = 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 = 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 = j - g 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 def shellSort(A, n):
    G = []
    h = 1
    while True:
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1

    cnt = 0
    print(len(G))
    G = list(reversed(G))
    for g in G:
        cnt += insertionSort(A, n, g)

    print(*G)
    print(cnt)
    print('\n'.join(map(str, A))) shellSort G = [] G [] h = 1 h 1 while True:
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1

     True if h > n:
            break
         h > n h n break G.append(h) G.append G append h h = 3 * h + 1 h 3 * h + 1 3 * h 3 h 1 cnt = 0 cnt 0 print(len(G)) print len(G) len G G = list(reversed(G)) G list(reversed(G)) list reversed(G) reversed G for g in G:
        cnt += insertionSort(A, n, g)

     g G cnt += insertionSort(A, n, g) cnt insertionSort(A, n, g) insertionSort A n g print(*G) print *G 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 A A n n arr_length = int(input()) arr_length int(input()) int input() input arr_num = [] arr_num [] for i in range(arr_length):
    arr_num.append(int(input())) i range(arr_length) range arr_length arr_num.append(int(input())) arr_num.append arr_num append int(input()) int input() input shellSort(arr_num, arr_length) shellSort arr_num arr_length arr_num = [] [] arr_num def insertionSort(A, n, g):
    cnt = 0
    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 = j - g
            cnt += 1
        A[j+g] = v
    return cnt def insertionSort(A, n, g):
    cnt = 0
    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 = j - g
            cnt += 1
        A[j+g] = v
    return cnt insertionSort arr_length = int(input()) int(input()) arr_length def shellSort(A, n):
    G = []
    h = 1
    while True:
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1

    cnt = 0
    print(len(G))
    G = list(reversed(G))
    for g in G:
        cnt += insertionSort(A, n, g)

    print(*G)
    print(cnt)
    print('\n'.join(map(str, A))) def shellSort(A, n):
    G = []
    h = 1
    while True:
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1

    cnt = 0
    print(len(G))
    G = list(reversed(G))
    for g in G:
        cnt += insertionSort(A, n, g)

    print(*G)
    print(cnt)
    print('\n'.join(map(str, A))) shellSort
def insertionSort(A, n, g):
    cnt = 0
    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 = j - g
            cnt += 1
        A[j+g] = v
    return cnt


def shellSort(A, n):
    G = []
    h = 1
    while True:
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1

    cnt = 0
    print(len(G))
    G = list(reversed(G))
    for g in G:
        cnt += insertionSort(A, n, g)

    print(*G)
    print(cnt)
    print('\n'.join(map(str, A)))


arr_length = int(input())
arr_num = []
for i in range(arr_length):
    arr_num.append(int(input()))

shellSort(arr_num, arr_length)
