cnt = 0


def insSort(A, n, g):
    global cnt

    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


def shellSort(A, n):
    G = []
    i = 1
    while True:
        G.append(i)
        i = i * 3 + 1
        if i > n - 2:
            break
    G.reverse()

    print(len(G))
    print(*G)

    for i in G:
        insSort(A, n, i)


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

shellSort(arr, n)

print(cnt)

for s in arr:
    print(s)
 cnt = 0 cnt 0 def insSort(A, n, g):
    global cnt

    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 insSort global cnt 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 A A n n g g def shellSort(A, n):
    G = []
    i = 1
    while True:
        G.append(i)
        i = i * 3 + 1
        if i > n - 2:
            break
    G.reverse()

    print(len(G))
    print(*G)

    for i in G:
        insSort(A, n, i) shellSort G = [] G [] i = 1 i 1 while True:
        G.append(i)
        i = i * 3 + 1
        if i > n - 2:
            break
     True G.append(i) G.append G append i i = i * 3 + 1 i i * 3 + 1 i * 3 i 3 1 if i > n - 2:
            break
     i > n - 2 i n - 2 n 2 break G.reverse() G.reverse G reverse print(len(G)) print len(G) len G print(*G) print *G G for i in G:
        insSort(A, n, i) i G insSort(A, n, i) insSort A n i A A n n n = int(input()) n int(input()) int input() input arr = [] arr [] for i in range(n):
    arr.append(int(input())) i range(n) range n arr.append(int(input())) arr.append arr append int(input()) int input() input shellSort(arr, n) shellSort arr n print(cnt) print cnt for s in arr:
    print(s) s arr print(s) print s def shellSort(A, n):
    G = []
    i = 1
    while True:
        G.append(i)
        i = i * 3 + 1
        if i > n - 2:
            break
    G.reverse()

    print(len(G))
    print(*G)

    for i in G:
        insSort(A, n, i) def shellSort(A, n):
    G = []
    i = 1
    while True:
        G.append(i)
        i = i * 3 + 1
        if i > n - 2:
            break
    G.reverse()

    print(len(G))
    print(*G)

    for i in G:
        insSort(A, n, i) shellSort arr = [] [] arr n = int(input()) int(input()) n cnt = 0 0 cnt def insSort(A, n, g):
    global cnt

    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 def insSort(A, n, g):
    global cnt

    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 insSort
cnt = 0


def insSort(A, n, g):
    global cnt

    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


def shellSort(A, n):
    G = []
    i = 1
    while True:
        G.append(i)
        i = i * 3 + 1
        if i > n - 2:
            break
    G.reverse()

    print(len(G))
    print(*G)

    for i in G:
        insSort(A, n, i)


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

shellSort(arr, n)

print(cnt)

for s in arr:
    print(s)

