cnt = 0
def insertionSort(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 -= g
            cnt += 1
        A[j+g] = v

def shellSort(A, n):
    gi = 2
    m = 1
    G = []
    for i in range(100):
        m += 1
        G.append(gi - 1)
        gi = gi * 2
        if n < gi - 1:
            break
    list.sort(G, reverse=True)
    for i in range(0, m-1):
        insertionSort(A, n, G[i])
    return G
      
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
G = shellSort(A, n)
G = [str(g) for g in G]
print(len(G))
print(" ".join(G))
print(cnt)
for a in A:
    print(a) cnt = 0 cnt 0 def insertionSort(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 -= g
            cnt += 1
        A[j+g] = v insertionSort 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 -= 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 -= 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 -= 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):
    gi = 2
    m = 1
    G = []
    for i in range(100):
        m += 1
        G.append(gi - 1)
        gi = gi * 2
        if n < gi - 1:
            break
    list.sort(G, reverse=True)
    for i in range(0, m-1):
        insertionSort(A, n, G[i])
    return G
       shellSort gi = 2 gi 2 m = 1 m 1 G = [] G [] for i in range(100):
        m += 1
        G.append(gi - 1)
        gi = gi * 2
        if n < gi - 1:
            break
     i range(100) range 100 m += 1 m 1 G.append(gi - 1) G.append G append gi - 1 gi 1 gi = gi * 2 gi gi * 2 gi 2 if n < gi - 1:
            break
     n < gi - 1 n gi - 1 gi 1 break list.sort(G, reverse=True) list.sort list sort G reverse=True reverse True for i in range(0, m-1):
        insertionSort(A, n, G[i])
     i range(0, m-1) range 0 m-1 m 1 insertionSort(A, n, G[i]) insertionSort A n G[i] G i return G G A A n n 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 G = shellSort(A, n) G shellSort(A, n) shellSort A n str(g) for g in G for g in G g G for g in G str(g) str g G = [str(g) for g in G] G [str(g) for g in G] print(len(G)) print len(G) len G print(" ".join(G)) print " ".join(G) " ".join " " join G print(cnt) print cnt for a in A:
    print(a) a A print(a) print a n = int(input()) int(input()) n G = shellSort(A, n) shellSort(A, n) G cnt = 0 0 cnt G = [str(g) for g in G] [str(g) for g in G] G A = [] [] A def insertionSort(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 -= g
            cnt += 1
        A[j+g] = v def insertionSort(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 -= g
            cnt += 1
        A[j+g] = v insertionSort def shellSort(A, n):
    gi = 2
    m = 1
    G = []
    for i in range(100):
        m += 1
        G.append(gi - 1)
        gi = gi * 2
        if n < gi - 1:
            break
    list.sort(G, reverse=True)
    for i in range(0, m-1):
        insertionSort(A, n, G[i])
    return G
       def shellSort(A, n):
    gi = 2
    m = 1
    G = []
    for i in range(100):
        m += 1
        G.append(gi - 1)
        gi = gi * 2
        if n < gi - 1:
            break
    list.sort(G, reverse=True)
    for i in range(0, m-1):
        insertionSort(A, n, G[i])
    return G
       shellSort
cnt = 0
def insertionSort(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 -= g
            cnt += 1
        A[j+g] = v

def shellSort(A, n):
    gi = 2
    m = 1
    G = []
    for i in range(100):
        m += 1
        G.append(gi - 1)
        gi = gi * 2
        if n < gi - 1:
            break
    list.sort(G, reverse=True)
    for i in range(0, m-1):
        insertionSort(A, n, G[i])
    return G
      
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
G = shellSort(A, n)
G = [str(g) for g in G]
print(len(G))
print(" ".join(G))
print(cnt)
for a in A:
    print(a)
