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


def shellSort(arr, N):
    cnt = 0
    G = []
    h = 0
    m = 0
    while h <= N / 9:
        h = 3 * h + 1
        G.append(h)
        m += 1
    G = G[::-1]

    cnt = sum([insertionSort(arr, N, g) for g in G])
    return (cnt, G)


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

(cnt, G) = shellSort(arr, N)
print(len(G), ' '.join(map(str, G)), cnt, '\n'.join(map(str, arr)), end='\n')
 def insertionSort(arr, N, g):
    cnt = 0
    for i in range(g, N):
        tmp = arr[i]
        j = i - g
        while(j >= 0 and arr[j] > tmp):
            arr[j + g] = arr[j]
            j -= g
            cnt += 1
        arr[j + g] = tmp
    return cnt insertionSort cnt = 0 cnt 0 for i in range(g, N):
        tmp = arr[i]
        j = i - g
        while(j >= 0 and arr[j] > tmp):
            arr[j + g] = arr[j]
            j -= g
            cnt += 1
        arr[j + g] = tmp
     i range(g, N) range g N tmp = arr[i] tmp arr[i] arr i j = i - g j i - g i g while(j >= 0 and arr[j] > tmp):
            arr[j + g] = arr[j]
            j -= g
            cnt += 1
         j >= 0 and arr[j] > tmp j >= 0 j 0 arr[j] > tmp arr[j] arr j tmp arr[j + g] = arr[j] arr[j + g] arr j + g j g arr[j] arr j j -= g j g cnt += 1 cnt 1 arr[j + g] = tmp arr[j + g] arr j + g j g tmp return cnt cnt arr arr N N g g def shellSort(arr, N):
    cnt = 0
    G = []
    h = 0
    m = 0
    while h <= N / 9:
        h = 3 * h + 1
        G.append(h)
        m += 1
    G = G[::-1]

    cnt = sum([insertionSort(arr, N, g) for g in G])
    return (cnt, G) shellSort cnt = 0 cnt 0 G = [] G [] h = 0 h 0 m = 0 m 0 while h <= N / 9:
        h = 3 * h + 1
        G.append(h)
        m += 1
     h <= N / 9 h N / 9 N 9 h = 3 * h + 1 h 3 * h + 1 3 * h 3 h 1 G.append(h) G.append G append h m += 1 m 1 G = G[::-1] G G[::-1] G ::-1 -1 insertionSort(arr, N, g) for g in G for g in G g G for g in G insertionSort(arr, N, g) insertionSort arr N g cnt = sum([insertionSort(arr, N, g) for g in G]) cnt sum([insertionSort(arr, N, g) for g in G]) sum [insertionSort(arr, N, g) for g in G] return (cnt, G) (cnt, G) cnt G arr arr 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 arr = [int(input()) for i in range(N)] arr [int(input()) for i in range(N)] (cnt, G) = shellSort(arr, N) (cnt, G) cnt G shellSort(arr, N) shellSort arr N print(len(G), ' '.join(map(str, G)), cnt, '\n'.join(map(str, arr)), end='\n') print len(G) len G ' '.join(map(str, G)) ' '.join ' ' join map(str, G) map str G cnt '\n'.join(map(str, arr)) '\n'.join '\n' join map(str, arr) map str arr end='\n' end '\n' N = int(input()) int(input()) N arr = [int(input()) for i in range(N)] [int(input()) for i in range(N)] arr def insertionSort(arr, N, g):
    cnt = 0
    for i in range(g, N):
        tmp = arr[i]
        j = i - g
        while(j >= 0 and arr[j] > tmp):
            arr[j + g] = arr[j]
            j -= g
            cnt += 1
        arr[j + g] = tmp
    return cnt def insertionSort(arr, N, g):
    cnt = 0
    for i in range(g, N):
        tmp = arr[i]
        j = i - g
        while(j >= 0 and arr[j] > tmp):
            arr[j + g] = arr[j]
            j -= g
            cnt += 1
        arr[j + g] = tmp
    return cnt insertionSort def shellSort(arr, N):
    cnt = 0
    G = []
    h = 0
    m = 0
    while h <= N / 9:
        h = 3 * h + 1
        G.append(h)
        m += 1
    G = G[::-1]

    cnt = sum([insertionSort(arr, N, g) for g in G])
    return (cnt, G) def shellSort(arr, N):
    cnt = 0
    G = []
    h = 0
    m = 0
    while h <= N / 9:
        h = 3 * h + 1
        G.append(h)
        m += 1
    G = G[::-1]

    cnt = sum([insertionSort(arr, N, g) for g in G])
    return (cnt, G) shellSort
def insertionSort(arr, N, g):
    cnt = 0
    for i in range(g, N):
        tmp = arr[i]
        j = i - g
        while(j >= 0 and arr[j] > tmp):
            arr[j + g] = arr[j]
            j -= g
            cnt += 1
        arr[j + g] = tmp
    return cnt


def shellSort(arr, N):
    cnt = 0
    G = []
    h = 0
    m = 0
    while h <= N / 9:
        h = 3 * h + 1
        G.append(h)
        m += 1
    G = G[::-1]

    cnt = sum([insertionSort(arr, N, g) for g in G])
    return (cnt, G)


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

(cnt, G) = shellSort(arr, N)
print(len(G), ' '.join(map(str, G)), cnt, '\n'.join(map(str, arr)), end='\n')

