def insertion_sort(A, N, exchange_cnt):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
            exchange_cnt += 1
        A[j + 1] = v
    return A, exchange_cnt

def shell_sort(A, N, G):
    exchange_cnt = 0
    for g in G:
        for i in range(g):
            A[i::g], exchange_cnt = insertion_sort(A[i::g], len(A[i::g]), exchange_cnt)
    return A, exchange_cnt
    

def determine_G(N):
    G = [1]
    for i in range(N):
        G.append(G[i]*3 + 1)
        if G[-1] >= N:
            del G[-1]
            break
    return G[::-1]

N = int(input().rstrip())

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

G = determine_G(N)

    
result = shell_sort(A, N, G)
print(len(G))
print(" ".join([str(g) for g in G]))
print(result[1])
for num in result[0]:
    print(num) def insertion_sort(A, N, exchange_cnt):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
            exchange_cnt += 1
        A[j + 1] = v
    return A, exchange_cnt insertion_sort for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
            exchange_cnt += 1
        A[j + 1] = v
     i range(1, N) range 1 N v = A[i] v A[i] A i j = i - 1 j i - 1 i 1 while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
            exchange_cnt += 1
         j >= 0 and A[j] > v j >= 0 j 0 A[j] > v A[j] A j v A[j + 1] = A[j] A[j + 1] A j + 1 j 1 A[j] A j j -= 1 j 1 exchange_cnt += 1 exchange_cnt 1 A[j + 1] = v A[j + 1] A j + 1 j 1 v return A, exchange_cnt return A, exchange_cnt A exchange_cnt A A N N exchange_cnt exchange_cnt def shell_sort(A, N, G):
    exchange_cnt = 0
    for g in G:
        for i in range(g):
            A[i::g], exchange_cnt = insertion_sort(A[i::g], len(A[i::g]), exchange_cnt)
    return A, exchange_cnt
     shell_sort exchange_cnt = 0 exchange_cnt 0 for g in G:
        for i in range(g):
            A[i::g], exchange_cnt = insertion_sort(A[i::g], len(A[i::g]), exchange_cnt)
     g G for i in range(g):
            A[i::g], exchange_cnt = insertion_sort(A[i::g], len(A[i::g]), exchange_cnt)
     i range(g) range g A[i::g], exchange_cnt = insertion_sort(A[i::g], len(A[i::g]), exchange_cnt) A[i::g] A i::g i g insertion_sort(A[i::g], len(A[i::g]), exchange_cnt) insertion_sort A[i::g] A i::g i g len(A[i::g]) len A[i::g] A i::g i g exchange_cnt exchange_cnt return A, exchange_cnt return A, exchange_cnt A exchange_cnt A A N N G G def determine_G(N):
    G = [1]
    for i in range(N):
        G.append(G[i]*3 + 1)
        if G[-1] >= N:
            del G[-1]
            break
    return G[::-1] determine_G G = [1] G [1] 1 for i in range(N):
        G.append(G[i]*3 + 1)
        if G[-1] >= N:
            del G[-1]
            break
     i range(N) range N G.append(G[i]*3 + 1) G.append G append G[i]*3 + 1 G[i]*3 G[i] G i 3 1 if G[-1] >= N:
            del G[-1]
            break
     G[-1] >= N G[-1] G -1 N del G[-1] G[-1] G -1 break return G[::-1] G[::-1] G ::-1 -1 N N N = int(input().rstrip()) N int(input().rstrip()) int input().rstrip() ().rstrip () input rstrip A = [] A [] for n in range(N):
    A.append(int(input().rstrip())) n range(N) range N A.append(int(input().rstrip())) A.append A append int(input().rstrip()) int input().rstrip() ().rstrip () input rstrip G = determine_G(N) G determine_G(N) determine_G N result = shell_sort(A, N, G) result shell_sort(A, N, G) shell_sort A N G print(len(G)) print len(G) len G str(g) for g in G for g in G g G for g in G str(g) str g print(" ".join([str(g) for g in G])) print " ".join([str(g) for g in G]) " ".join " " join [str(g) for g in G] print(result[1]) print result[1] result 1 for num in result[0]:
    print(num) num result[0] result 0 print(num) print num A = [] [] A def insertion_sort(A, N, exchange_cnt):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
            exchange_cnt += 1
        A[j + 1] = v
    return A, exchange_cnt def insertion_sort(A, N, exchange_cnt):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
            exchange_cnt += 1
        A[j + 1] = v
    return A, exchange_cnt insertion_sort result = shell_sort(A, N, G) shell_sort(A, N, G) result def determine_G(N):
    G = [1]
    for i in range(N):
        G.append(G[i]*3 + 1)
        if G[-1] >= N:
            del G[-1]
            break
    return G[::-1] def determine_G(N):
    G = [1]
    for i in range(N):
        G.append(G[i]*3 + 1)
        if G[-1] >= N:
            del G[-1]
            break
    return G[::-1] determine_G N = int(input().rstrip()) int(input().rstrip()) N G = determine_G(N) determine_G(N) G def shell_sort(A, N, G):
    exchange_cnt = 0
    for g in G:
        for i in range(g):
            A[i::g], exchange_cnt = insertion_sort(A[i::g], len(A[i::g]), exchange_cnt)
    return A, exchange_cnt
     def shell_sort(A, N, G):
    exchange_cnt = 0
    for g in G:
        for i in range(g):
            A[i::g], exchange_cnt = insertion_sort(A[i::g], len(A[i::g]), exchange_cnt)
    return A, exchange_cnt
     shell_sort
def insertion_sort(A, N, exchange_cnt):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
            exchange_cnt += 1
        A[j + 1] = v
    return A, exchange_cnt

def shell_sort(A, N, G):
    exchange_cnt = 0
    for g in G:
        for i in range(g):
            A[i::g], exchange_cnt = insertion_sort(A[i::g], len(A[i::g]), exchange_cnt)
    return A, exchange_cnt
    

def determine_G(N):
    G = [1]
    for i in range(N):
        G.append(G[i]*3 + 1)
        if G[-1] >= N:
            del G[-1]
            break
    return G[::-1]

N = int(input().rstrip())

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

G = determine_G(N)

    
result = shell_sort(A, N, G)
print(len(G))
print(" ".join([str(g) for g in G]))
print(result[1])
for num in result[0]:
    print(num)
