def insertionSort(A, n, gap):
    cnt = 0
    for i in range(gap, n):
        v = A[i]
        j = i - gap
        while j >= 0 and A[j] > v:
            cnt += 1
            A[j + gap] = A[j]
            j = j - gap
        A[j + gap] = v
    return cnt


def shellSort(A, n):
    if len(A) == 1:
        print(1,1,0,A[0],sep='\n')
        return
    cnt = 0
    G = []
    m = 1
    while (3**m - 1) // 2 < n:
        G.append((3**m - 1) // 2)
        m += 1
    m -= 1
    print(m)
    for i in range(m):
        cnt += insertionSort(A, n, G[m - i - 1])
    print(*G[::-1])
    print(cnt)
    print(*A, sep='\n')

N = int(input())
A = list([int(input()) for i in range(N)])
shellSort(A, N) def insertionSort(A, n, gap):
    cnt = 0
    for i in range(gap, n):
        v = A[i]
        j = i - gap
        while j >= 0 and A[j] > v:
            cnt += 1
            A[j + gap] = A[j]
            j = j - gap
        A[j + gap] = v
    return cnt insertionSort cnt = 0 cnt 0 for i in range(gap, n):
        v = A[i]
        j = i - gap
        while j >= 0 and A[j] > v:
            cnt += 1
            A[j + gap] = A[j]
            j = j - gap
        A[j + gap] = v
     i range(gap, n) range gap n v = A[i] v A[i] A i j = i - gap j i - gap i gap while j >= 0 and A[j] > v:
            cnt += 1
            A[j + gap] = A[j]
            j = j - gap
         j >= 0 and A[j] > v j >= 0 j 0 A[j] > v A[j] A j v cnt += 1 cnt 1 A[j + gap] = A[j] A[j + gap] A j + gap j gap A[j] A j j = j - gap j j - gap j gap A[j + gap] = v A[j + gap] A j + gap j gap v return cnt cnt A A n n gap gap def shellSort(A, n):
    if len(A) == 1:
        print(1,1,0,A[0],sep='\n')
        return
    cnt = 0
    G = []
    m = 1
    while (3**m - 1) // 2 < n:
        G.append((3**m - 1) // 2)
        m += 1
    m -= 1
    print(m)
    for i in range(m):
        cnt += insertionSort(A, n, G[m - i - 1])
    print(*G[::-1])
    print(cnt)
    print(*A, sep='\n') shellSort if len(A) == 1:
        print(1,1,0,A[0],sep='\n')
        return
     len(A) == 1 len(A) len A 1 print(1,1,0,A[0],sep='\n') print 1 1 0 A[0] A 0 sep='\n' sep '\n' return cnt = 0 cnt 0 G = [] G [] m = 1 m 1 while (3**m - 1) // 2 < n:
        G.append((3**m - 1) // 2)
        m += 1
     (3**m - 1) // 2 < n (3**m - 1) // 2 3**m - 1 3**m 3 m 1 2 n G.append((3**m - 1) // 2) G.append G append (3**m - 1) // 2 3**m - 1 3**m 3 m 1 2 m += 1 m 1 m -= 1 m 1 print(m) print m for i in range(m):
        cnt += insertionSort(A, n, G[m - i - 1])
     i range(m) range m cnt += insertionSort(A, n, G[m - i - 1]) cnt insertionSort(A, n, G[m - i - 1]) insertionSort A n G[m - i - 1] G m - i - 1 m - i m i 1 print(*G[::-1]) print *G[::-1] G[::-1] G ::-1 -1 print(cnt) print cnt print(*A, sep='\n') print *A A sep='\n' sep '\n' A A n n N = int(input()) N int(input()) int input() input int(input()) for i in range(N) for i in range(N) i range(N) range N for i in range(N) int(input()) int input() input A = list([int(input()) for i in range(N)]) A list([int(input()) for i in range(N)]) list [int(input()) for i in range(N)] shellSort(A, N) shellSort A N A = list([int(input()) for i in range(N)]) list([int(input()) for i in range(N)]) A def shellSort(A, n):
    if len(A) == 1:
        print(1,1,0,A[0],sep='\n')
        return
    cnt = 0
    G = []
    m = 1
    while (3**m - 1) // 2 < n:
        G.append((3**m - 1) // 2)
        m += 1
    m -= 1
    print(m)
    for i in range(m):
        cnt += insertionSort(A, n, G[m - i - 1])
    print(*G[::-1])
    print(cnt)
    print(*A, sep='\n') def shellSort(A, n):
    if len(A) == 1:
        print(1,1,0,A[0],sep='\n')
        return
    cnt = 0
    G = []
    m = 1
    while (3**m - 1) // 2 < n:
        G.append((3**m - 1) // 2)
        m += 1
    m -= 1
    print(m)
    for i in range(m):
        cnt += insertionSort(A, n, G[m - i - 1])
    print(*G[::-1])
    print(cnt)
    print(*A, sep='\n') shellSort N = int(input()) int(input()) N def insertionSort(A, n, gap):
    cnt = 0
    for i in range(gap, n):
        v = A[i]
        j = i - gap
        while j >= 0 and A[j] > v:
            cnt += 1
            A[j + gap] = A[j]
            j = j - gap
        A[j + gap] = v
    return cnt def insertionSort(A, n, gap):
    cnt = 0
    for i in range(gap, n):
        v = A[i]
        j = i - gap
        while j >= 0 and A[j] > v:
            cnt += 1
            A[j + gap] = A[j]
            j = j - gap
        A[j + gap] = v
    return cnt insertionSort
def insertionSort(A, n, gap):
    cnt = 0
    for i in range(gap, n):
        v = A[i]
        j = i - gap
        while j >= 0 and A[j] > v:
            cnt += 1
            A[j + gap] = A[j]
            j = j - gap
        A[j + gap] = v
    return cnt


def shellSort(A, n):
    if len(A) == 1:
        print(1,1,0,A[0],sep='\n')
        return
    cnt = 0
    G = []
    m = 1
    while (3**m - 1) // 2 < n:
        G.append((3**m - 1) // 2)
        m += 1
    m -= 1
    print(m)
    for i in range(m):
        cnt += insertionSort(A, n, G[m - i - 1])
    print(*G[::-1])
    print(cnt)
    print(*A, sep='\n')

N = int(input())
A = list([int(input()) for i in range(N)])
shellSort(A, N)