def insertion_sort(A, g):
    cnt = 0
    for i in range(g, len(A)):
        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
    return cnt

def shell_sort(A):
    cnt = 0
    h = 1
    G = []
    while h <= len(A)/2:
        G.append(h)
        h = 3 * h + 1
    if len(G) == 0:
        G.append(1)
    print(len(G))
    print(*G[::-1])
    for g_i in G[::-1]:
        cnt += insertion_sort(A, g_i)
    return cnt

if __name__ == '__main__':
    n = int(input())
    A = []
    for i in range(n):
        A.append(int(input()))

    print(shell_sort(A))
    for a in A:
        print(a)
 def insertion_sort(A, g):
    cnt = 0
    for i in range(g, len(A)):
        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
    return cnt insertion_sort cnt = 0 cnt 0 for i in range(g, len(A)):
        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, len(A)) range g len(A) len A 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 return cnt cnt A A g g def shell_sort(A):
    cnt = 0
    h = 1
    G = []
    while h <= len(A)/2:
        G.append(h)
        h = 3 * h + 1
    if len(G) == 0:
        G.append(1)
    print(len(G))
    print(*G[::-1])
    for g_i in G[::-1]:
        cnt += insertion_sort(A, g_i)
    return cnt shell_sort cnt = 0 cnt 0 h = 1 h 1 G = [] G [] while h <= len(A)/2:
        G.append(h)
        h = 3 * h + 1
     h <= len(A)/2 h len(A)/2 len(A) len A 2 G.append(h) G.append G append h h = 3 * h + 1 h 3 * h + 1 3 * h 3 h 1 if len(G) == 0:
        G.append(1)
     len(G) == 0 len(G) len G 0 G.append(1) G.append G append 1 print(len(G)) print len(G) len G print(*G[::-1]) print *G[::-1] G[::-1] G ::-1 -1 for g_i in G[::-1]:
        cnt += insertion_sort(A, g_i)
     g_i G[::-1] G ::-1 -1 cnt += insertion_sort(A, g_i) cnt insertion_sort(A, g_i) insertion_sort A g_i return cnt cnt A A if __name__ == '__main__':
    n = int(input())
    A = []
    for i in range(n):
        A.append(int(input()))

    print(shell_sort(A))
    for a in A:
        print(a) __name__ == '__main__' __name__ '__main__' 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 print(shell_sort(A)) print shell_sort(A) shell_sort A for a in A:
        print(a) a A print(a) print a def insertion_sort(A, g):
    cnt = 0
    for i in range(g, len(A)):
        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
    return cnt def insertion_sort(A, g):
    cnt = 0
    for i in range(g, len(A)):
        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
    return cnt insertion_sort def shell_sort(A):
    cnt = 0
    h = 1
    G = []
    while h <= len(A)/2:
        G.append(h)
        h = 3 * h + 1
    if len(G) == 0:
        G.append(1)
    print(len(G))
    print(*G[::-1])
    for g_i in G[::-1]:
        cnt += insertion_sort(A, g_i)
    return cnt def shell_sort(A):
    cnt = 0
    h = 1
    G = []
    while h <= len(A)/2:
        G.append(h)
        h = 3 * h + 1
    if len(G) == 0:
        G.append(1)
    print(len(G))
    print(*G[::-1])
    for g_i in G[::-1]:
        cnt += insertion_sort(A, g_i)
    return cnt shell_sort n = int(input()) int(input()) n A = [] [] A
def insertion_sort(A, g):
    cnt = 0
    for i in range(g, len(A)):
        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
    return cnt

def shell_sort(A):
    cnt = 0
    h = 1
    G = []
    while h <= len(A)/2:
        G.append(h)
        h = 3 * h + 1
    if len(G) == 0:
        G.append(1)
    print(len(G))
    print(*G[::-1])
    for g_i in G[::-1]:
        cnt += insertion_sort(A, g_i)
    return cnt

if __name__ == '__main__':
    n = int(input())
    A = []
    for i in range(n):
        A.append(int(input()))

    print(shell_sort(A))
    for a in A:
        print(a)

