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')



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):

    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')



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")

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):
    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")

-cnt = 0 - - -    global cnt +    cnt = 0 +    return cnt +        G.append(h) -        G.append(h) -    for g in G: -        insertionSort(arr, N, g) -    return G +    cnt = sum([insertionSort(arr, N, g) for g in G]) +    return (cnt, G) -G = shellSort(arr, N) +(cnt, G) = shellSort(arr, N)