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

def shellSort(A, n):
    cnt = 0
    m = 1
    G = []
    
    h = 1
    while (h < n // 3):
        h = h * 3 + 1
        m += 1

    # print(f'm: {m}')

    while True:
        G.append(h)
        if h == 1:
            break
        h //= 3

    # print(f'G: {G}')
    
    for i in range(m):
        ans = insertionSort(A, n, G[i])
        # print(ans)
        A = ans[0]
        cnt += ans[1]

    return m, G, A, cnt


n = int(input())
A = [int(input()) for _ in range(n)]

m, G, A, cnt = shellSort(A, n)

print(m)
print(' '.join(str(g) for g in G))
print(cnt)
for a in A:
    print(a) def insertionSort(A, n, g):
    local_cnt = 0
    for i in range(g, n):
        # print(i, local_cnt)
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            # print(i, j, local_cnt)
            A[j + g] = A[j]
            j -= g
            local_cnt += 1
        A[j + g] = v
    return A, local_cnt insertionSort local_cnt = 0 local_cnt 0 for i in range(g, n):
        # print(i, local_cnt)
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            # print(i, j, local_cnt)
            A[j + g] = A[j]
            j -= g
            local_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:
            # print(i, j, local_cnt)
            A[j + g] = A[j]
            j -= g
            local_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 local_cnt += 1 local_cnt 1 A[j + g] = v A[j + g] A j + g j g v return A, local_cnt return A, local_cnt A local_cnt A A n n g g def shellSort(A, n):
    cnt = 0
    m = 1
    G = []
    
    h = 1
    while (h < n // 3):
        h = h * 3 + 1
        m += 1

    # print(f'm: {m}')

    while True:
        G.append(h)
        if h == 1:
            break
        h //= 3

    # print(f'G: {G}')
    
    for i in range(m):
        ans = insertionSort(A, n, G[i])
        # print(ans)
        A = ans[0]
        cnt += ans[1]

    return m, G, A, cnt shellSort cnt = 0 cnt 0 m = 1 m 1 G = [] G [] h = 1 h 1 while (h < n // 3):
        h = h * 3 + 1
        m += 1

    # print(f'm: {m}')

     h < n // 3 h n // 3 n 3 h = h * 3 + 1 h h * 3 + 1 h * 3 h 3 1 m += 1 m 1 while True:
        G.append(h)
        if h == 1:
            break
        h //= 3

    # print(f'G: {G}')
    
     True G.append(h) G.append G append h if h == 1:
            break
         h == 1 h 1 break h //= 3 h 3 for i in range(m):
        ans = insertionSort(A, n, G[i])
        # print(ans)
        A = ans[0]
        cnt += ans[1]

     i range(m) range m ans = insertionSort(A, n, G[i]) ans insertionSort(A, n, G[i]) insertionSort A n G[i] G i A = ans[0] A ans[0] ans 0 cnt += ans[1] cnt ans[1] ans 1 return m, G, A, cnt return m, G, A, cnt m G A cnt A A n n n = int(input()) n int(input()) int input() input int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input A = [int(input()) for _ in range(n)] A [int(input()) for _ in range(n)] m, G, A, cnt = shellSort(A, n) m shellSort(A, n) shellSort A n G A cnt print(m) print m print(' '.join(str(g) for g in G)) print ' '.join(str(g) for g in G) ' '.join ' ' join str(g) str g print(cnt) print cnt for a in A:
    print(a) a A print(a) print a A = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] A m, G, A, cnt = shellSort(A, n) shellSort(A, n) m G, A, cnt = shellSort(A, n) shellSort(A, n) G def shellSort(A, n):
    cnt = 0
    m = 1
    G = []
    
    h = 1
    while (h < n // 3):
        h = h * 3 + 1
        m += 1

    # print(f'm: {m}')

    while True:
        G.append(h)
        if h == 1:
            break
        h //= 3

    # print(f'G: {G}')
    
    for i in range(m):
        ans = insertionSort(A, n, G[i])
        # print(ans)
        A = ans[0]
        cnt += ans[1]

    return m, G, A, cnt def shellSort(A, n):
    cnt = 0
    m = 1
    G = []
    
    h = 1
    while (h < n // 3):
        h = h * 3 + 1
        m += 1

    # print(f'm: {m}')

    while True:
        G.append(h)
        if h == 1:
            break
        h //= 3

    # print(f'G: {G}')
    
    for i in range(m):
        ans = insertionSort(A, n, G[i])
        # print(ans)
        A = ans[0]
        cnt += ans[1]

    return m, G, A, cnt shellSort n = int(input()) int(input()) n cnt = shellSort(A, n) shellSort(A, n) cnt def insertionSort(A, n, g):
    local_cnt = 0
    for i in range(g, n):
        # print(i, local_cnt)
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            # print(i, j, local_cnt)
            A[j + g] = A[j]
            j -= g
            local_cnt += 1
        A[j + g] = v
    return A, local_cnt def insertionSort(A, n, g):
    local_cnt = 0
    for i in range(g, n):
        # print(i, local_cnt)
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            # print(i, j, local_cnt)
            A[j + g] = A[j]
            j -= g
            local_cnt += 1
        A[j + g] = v
    return A, local_cnt insertionSort A, cnt = shellSort(A, n) shellSort(A, n) A
def insertionSort(A, n, g):
    local_cnt = 0
    for i in range(g, n):
        # print(i, local_cnt)
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            # print(i, j, local_cnt)
            A[j + g] = A[j]
            j -= g
            local_cnt += 1
        A[j + g] = v
    return A, local_cnt

def shellSort(A, n):
    cnt = 0
    m = 1
    G = []
    
    h = 1
    while (h < n // 3):
        h = h * 3 + 1
        m += 1

    # print(f'm: {m}')

    while True:
        G.append(h)
        if h == 1:
            break
        h //= 3

    # print(f'G: {G}')
    
    for i in range(m):
        ans = insertionSort(A, n, G[i])
        # print(ans)
        A = ans[0]
        cnt += ans[1]

    return m, G, A, cnt


n = int(input())
A = [int(input()) for _ in range(n)]

m, G, A, cnt = shellSort(A, n)

print(m)
print(' '.join(str(g) for g in G))
print(cnt)
for a in A:
    print(a)
