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

def shell_sort(A, n):
    cnt = 0
    h = 1
    g = []
    while h <= n:
        g.append(h)
        h = 3*h + 1
    g.reverse()
    m = len(g)
    for i in range(m):
        cnt = insertion_sort(A, n, g[i], cnt)
    show(n, m, g, A, cnt)

def show(n, m, G, A, cnt):
    print(m)
    for i in range(m):
        if i != m-1:
            print(G[i], end = " ")
        else:
            print(G[i])
    print(cnt)
    for i in range(n):
        print(A[i])

if "__main__" == __name__:
    n = int(input())
    data = []
    for i in range(n):
        data.append(int(input()))
    shell_sort(data, n) def insertion_sort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and v < A[j]:
            A[j+g] = A[j]
            j -= g
            cnt += 1
            A[j+g] = v
    return cnt insertion_sort for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and v < A[j]:
            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 v < A[j]:
            A[j+g] = A[j]
            j -= g
            cnt += 1
            A[j+g] = v
     j >= 0 and v < A[j] j >= 0 j 0 v < A[j] v A[j] A j 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 return cnt cnt A A n n g g cnt cnt def shell_sort(A, n):
    cnt = 0
    h = 1
    g = []
    while h <= n:
        g.append(h)
        h = 3*h + 1
    g.reverse()
    m = len(g)
    for i in range(m):
        cnt = insertion_sort(A, n, g[i], cnt)
    show(n, m, g, A, cnt) shell_sort cnt = 0 cnt 0 h = 1 h 1 g = [] g [] while h <= n:
        g.append(h)
        h = 3*h + 1
     h <= n h n g.append(h) g.append g append h h = 3*h + 1 h 3*h + 1 3*h 3 h 1 g.reverse() g.reverse g reverse m = len(g) m len(g) len g for i in range(m):
        cnt = insertion_sort(A, n, g[i], cnt)
     i range(m) range m cnt = insertion_sort(A, n, g[i], cnt) cnt insertion_sort(A, n, g[i], cnt) insertion_sort A n g[i] g i cnt show(n, m, g, A, cnt) show n m g A cnt A A n n def show(n, m, G, A, cnt):
    print(m)
    for i in range(m):
        if i != m-1:
            print(G[i], end = " ")
        else:
            print(G[i])
    print(cnt)
    for i in range(n):
        print(A[i]) show print(m) print m for i in range(m):
        if i != m-1:
            print(G[i], end = " ")
        else:
            print(G[i])
     i range(m) range m if i != m-1:
            print(G[i], end = " ")
        else:
            print(G[i])
     i != m-1 i m-1 m 1 print(G[i], end = " ") print G[i] G i end = " " end " " print(G[i]) print G[i] G i print(cnt) print cnt for i in range(n):
        print(A[i]) i range(n) range n print(A[i]) print A[i] A i n n m m G G A A cnt cnt if "__main__" == __name__:
    n = int(input())
    data = []
    for i in range(n):
        data.append(int(input()))
    shell_sort(data, n) "__main__" == __name__ "__main__" __name__ n = int(input()) n int(input()) int input() input data = [] data [] for i in range(n):
        data.append(int(input()))
     i range(n) range n data.append(int(input())) data.append data append int(input()) int input() input shell_sort(data, n) shell_sort data n data = [] [] data def shell_sort(A, n):
    cnt = 0
    h = 1
    g = []
    while h <= n:
        g.append(h)
        h = 3*h + 1
    g.reverse()
    m = len(g)
    for i in range(m):
        cnt = insertion_sort(A, n, g[i], cnt)
    show(n, m, g, A, cnt) def shell_sort(A, n):
    cnt = 0
    h = 1
    g = []
    while h <= n:
        g.append(h)
        h = 3*h + 1
    g.reverse()
    m = len(g)
    for i in range(m):
        cnt = insertion_sort(A, n, g[i], cnt)
    show(n, m, g, A, cnt) shell_sort def show(n, m, G, A, cnt):
    print(m)
    for i in range(m):
        if i != m-1:
            print(G[i], end = " ")
        else:
            print(G[i])
    print(cnt)
    for i in range(n):
        print(A[i]) def show(n, m, G, A, cnt):
    print(m)
    for i in range(m):
        if i != m-1:
            print(G[i], end = " ")
        else:
            print(G[i])
    print(cnt)
    for i in range(n):
        print(A[i]) show n = int(input()) int(input()) n def insertion_sort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and v < A[j]:
            A[j+g] = A[j]
            j -= g
            cnt += 1
            A[j+g] = v
    return cnt def insertion_sort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and v < A[j]:
            A[j+g] = A[j]
            j -= g
            cnt += 1
            A[j+g] = v
    return cnt insertion_sort
def insertion_sort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and v < A[j]:
            A[j+g] = A[j]
            j -= g
            cnt += 1
            A[j+g] = v
    return cnt

def shell_sort(A, n):
    cnt = 0
    h = 1
    g = []
    while h <= n:
        g.append(h)
        h = 3*h + 1
    g.reverse()
    m = len(g)
    for i in range(m):
        cnt = insertion_sort(A, n, g[i], cnt)
    show(n, m, g, A, cnt)

def show(n, m, G, A, cnt):
    print(m)
    for i in range(m):
        if i != m-1:
            print(G[i], end = " ")
        else:
            print(G[i])
    print(cnt)
    for i in range(n):
        print(A[i])

if "__main__" == __name__:
    n = int(input())
    data = []
    for i in range(n):
        data.append(int(input()))
    shell_sort(data, n)
