cnt = 0


def insertionSort(arr, N, g):
    global cnt
    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


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


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

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


def insertionSort(arr, N, g):
    global cnt
    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


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


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

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

