# -*- coding: utf-8 -*-


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):
    cnt = 0
    m = 1
    G = []
    while True:
        if n < int((3 ** m - 1) / 2):
            m -= 1
            break
        else:
            G.append(int((3 ** m - 1) / 2))
            m += 1

    G.reverse()

    for i in range(m):
        cnt += insertionSort(A, n, G[i])

    print_line(A, G, m, cnt)


def print_line(A, G, m, cnt):
    print(m)
    for i in range(len(G)):
        if i == len(G) - 1:
            print(G[i])
        else:
            print("{0}".format(G[i]), end=' ')
    print(cnt)
    for i in range(len(A)):
        print(A[i])

A = []
n = int(input())
for i in range(n):
    A.append(int(input()))

shellSort(A, n) 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):
    cnt = 0
    m = 1
    G = []
    while True:
        if n < int((3 ** m - 1) / 2):
            m -= 1
            break
        else:
            G.append(int((3 ** m - 1) / 2))
            m += 1

    G.reverse()

    for i in range(m):
        cnt += insertionSort(A, n, G[i])

    print_line(A, G, m, cnt) shellSort cnt = 0 cnt 0 m = 1 m 1 G = [] G [] while True:
        if n < int((3 ** m - 1) / 2):
            m -= 1
            break
        else:
            G.append(int((3 ** m - 1) / 2))
            m += 1

     True if n < int((3 ** m - 1) / 2):
            m -= 1
            break
        else:
            G.append(int((3 ** m - 1) / 2))
            m += 1

     n < int((3 ** m - 1) / 2) n int((3 ** m - 1) / 2) int (3 ** m - 1) / 2 3 ** m - 1 3 ** m 3 m 1 2 m -= 1 m 1 break G.append(int((3 ** m - 1) / 2)) G.append G append int((3 ** m - 1) / 2) int (3 ** m - 1) / 2 3 ** m - 1 3 ** m 3 m 1 2 m += 1 m 1 G.reverse() G.reverse G reverse for i in range(m):
        cnt += insertionSort(A, n, G[i])

     i range(m) range m cnt += insertionSort(A, n, G[i]) cnt insertionSort(A, n, G[i]) insertionSort A n G[i] G i print_line(A, G, m, cnt) print_line A G m cnt A A n n def print_line(A, G, m, cnt):
    print(m)
    for i in range(len(G)):
        if i == len(G) - 1:
            print(G[i])
        else:
            print("{0}".format(G[i]), end=' ')
    print(cnt)
    for i in range(len(A)):
        print(A[i]) print_line print(m) print m for i in range(len(G)):
        if i == len(G) - 1:
            print(G[i])
        else:
            print("{0}".format(G[i]), end=' ')
     i range(len(G)) range len(G) len G if i == len(G) - 1:
            print(G[i])
        else:
            print("{0}".format(G[i]), end=' ')
     i == len(G) - 1 i len(G) - 1 len(G) len G 1 print(G[i]) print G[i] G i print("{0}".format(G[i]), end=' ') print "{0}".format(G[i]) "{0}".format "{0}" format G[i] G i end=' ' end ' ' print(cnt) print cnt for i in range(len(A)):
        print(A[i]) i range(len(A)) range len(A) len A print(A[i]) print A[i] A i A A G G m m cnt cnt A = [] A [] n = int(input()) n int(input()) int input() input for i in range(n):
    A.append(int(input())) i range(n) range n A.append(int(input())) A.append A append int(input()) int input() input shellSort(A, n) shellSort A n def print_line(A, G, m, cnt):
    print(m)
    for i in range(len(G)):
        if i == len(G) - 1:
            print(G[i])
        else:
            print("{0}".format(G[i]), end=' ')
    print(cnt)
    for i in range(len(A)):
        print(A[i]) def print_line(A, G, m, cnt):
    print(m)
    for i in range(len(G)):
        if i == len(G) - 1:
            print(G[i])
        else:
            print("{0}".format(G[i]), end=' ')
    print(cnt)
    for i in range(len(A)):
        print(A[i]) print_line 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 A = [] [] A n = int(input()) int(input()) n def shellSort(A, n):
    cnt = 0
    m = 1
    G = []
    while True:
        if n < int((3 ** m - 1) / 2):
            m -= 1
            break
        else:
            G.append(int((3 ** m - 1) / 2))
            m += 1

    G.reverse()

    for i in range(m):
        cnt += insertionSort(A, n, G[i])

    print_line(A, G, m, cnt) def shellSort(A, n):
    cnt = 0
    m = 1
    G = []
    while True:
        if n < int((3 ** m - 1) / 2):
            m -= 1
            break
        else:
            G.append(int((3 ** m - 1) / 2))
            m += 1

    G.reverse()

    for i in range(m):
        cnt += insertionSort(A, n, G[i])

    print_line(A, G, m, cnt) shellSort
# -*- coding: utf-8 -*-


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):
    cnt = 0
    m = 1
    G = []
    while True:
        if n < int((3 ** m - 1) / 2):
            m -= 1
            break
        else:
            G.append(int((3 ** m - 1) / 2))
            m += 1

    G.reverse()

    for i in range(m):
        cnt += insertionSort(A, n, G[i])

    print_line(A, G, m, cnt)


def print_line(A, G, m, cnt):
    print(m)
    for i in range(len(G)):
        if i == len(G) - 1:
            print(G[i])
        else:
            print("{0}".format(G[i]), end=' ')
    print(cnt)
    for i in range(len(A)):
        print(A[i])

A = []
n = int(input())
for i in range(n):
    A.append(int(input()))

shellSort(A, n)
