# シェルソート

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

cnt = 0


def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        for j in range(i-g, -1, -g):
            if A[j+g] < A[j]:
                A[j + g], A[j] = A[j], A[j + g]
                cnt += 1
            else:
                break


def shellSort(A, n):
    # gn+1 = 3gn + 1
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    print(len(G))
    print(" ".join([str(x) for x in G]))
    for g in G:
        insertionSort(A, n, g)


shellSort(A, N)
print(cnt)
for a in A:
    print(a)
 N = int(input()) N int(input()) int input() input A = [] A [] 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 cnt = 0 cnt 0 def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        for j in range(i-g, -1, -g):
            if A[j+g] < A[j]:
                A[j + g], A[j] = A[j], A[j + g]
                cnt += 1
            else:
                break insertionSort global cnt for i in range(g, n):
        for j in range(i-g, -1, -g):
            if A[j+g] < A[j]:
                A[j + g], A[j] = A[j], A[j + g]
                cnt += 1
            else:
                break i range(g, n) range g n for j in range(i-g, -1, -g):
            if A[j+g] < A[j]:
                A[j + g], A[j] = A[j], A[j + g]
                cnt += 1
            else:
                break j range(i-g, -1, -g) range i-g i g -1 -g g if A[j+g] < A[j]:
                A[j + g], A[j] = A[j], A[j + g]
                cnt += 1
            else:
                break A[j+g] < A[j] A[j+g] A j+g j g A[j] A j A[j + g], A[j] = A[j], A[j + g] A[j + g] A j + g j g A[j] A j A[j] A j A[j + g] A j + g j g cnt += 1 cnt 1 break A A n n g g def shellSort(A, n):
    # gn+1 = 3gn + 1
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    print(len(G))
    print(" ".join([str(x) for x in G]))
    for g in G:
        insertionSort(A, n, g) shellSort h = 1 h 1 G = [] G [] while h <= n:
        G.append(h)
        h = 3 * h + 1
     h <= n h n G.append(h) G.append G append h h = 3 * h + 1 h 3 * h + 1 3 * h 3 h 1 G.reverse() G.reverse G reverse print(len(G)) print len(G) len G str(x) for x in G for x in G x G for x in G str(x) str x print(" ".join([str(x) for x in G])) print " ".join([str(x) for x in G]) " ".join " " join [str(x) for x in G] for g in G:
        insertionSort(A, n, g) g G insertionSort(A, n, g) insertionSort A n g A A n n shellSort(A, N) shellSort A N print(cnt) print cnt for a in A:
    print(a) a A print(a) print a def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        for j in range(i-g, -1, -g):
            if A[j+g] < A[j]:
                A[j + g], A[j] = A[j], A[j + g]
                cnt += 1
            else:
                break def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        for j in range(i-g, -1, -g):
            if A[j+g] < A[j]:
                A[j + g], A[j] = A[j], A[j + g]
                cnt += 1
            else:
                break insertionSort cnt = 0 0 cnt N = int(input()) int(input()) N def shellSort(A, n):
    # gn+1 = 3gn + 1
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    print(len(G))
    print(" ".join([str(x) for x in G]))
    for g in G:
        insertionSort(A, n, g) def shellSort(A, n):
    # gn+1 = 3gn + 1
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    print(len(G))
    print(" ".join([str(x) for x in G]))
    for g in G:
        insertionSort(A, n, g) shellSort A = [] [] A
# シェルソート

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

cnt = 0


def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        for j in range(i-g, -1, -g):
            if A[j+g] < A[j]:
                A[j + g], A[j] = A[j], A[j + g]
                cnt += 1
            else:
                break


def shellSort(A, n):
    # gn+1 = 3gn + 1
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    print(len(G))
    print(" ".join([str(x) for x in G]))
    for g in G:
        insertionSort(A, n, g)


shellSort(A, N)
print(cnt)
for a in A:
    print(a)

