def insertionSort(arr, g):
    cnt = 0
    for i in range(g, len(arr)):
        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):
    cnt = 0
    g = []
    h = 0
    while h <= len(arr) / 9:
        h = 3 * h + 1
        g.append(h)
    g = g[::-1]
    m = len(g)

    for i in range(0, m):
        cnt += insertionSort(arr, g[i])
    return (cnt, g)


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

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

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

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

    for i in range(0, m):
        cnt += insertionSort(arr, g[i])
    return (cnt, g) shellSort 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, g):
    cnt = 0
    for i in range(g, len(arr)):
        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, g):
    cnt = 0
    for i in range(g, len(arr)):
        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 insertionSort(arr, g):
    cnt = 0
    for i in range(g, len(arr)):
        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):
    cnt = 0
    g = []
    h = 0
    while h <= len(arr) / 9:
        h = 3 * h + 1
        g.append(h)
    g = g[::-1]
    m = len(g)

    for i in range(0, m):
        cnt += insertionSort(arr, g[i])
    return (cnt, g)


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

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

