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

def shellSort(A, n):
    cnt = 0
    a = 1
    G = []
    while a <= n:
        G.append(a)
        a = 3*a + 1
    m = len(G)
    G = G[::-1]
    for i in range(0, m):
        cnt, A = insertionSort(A, n, G[i], cnt)
    return [m, G, cnt, A]
        
if __name__ == "__main__":
    n = int(input())
    A = [int(input()) for _ in range(n)]
    m, G, cnt, A = shellSort(A, n)
    print(m)
    print(*G)
    print(cnt)
    for i in A:
        print(i) def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return [cnt, A] insertionSort for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            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 A[j] > v:
            A[j+g] = A[j]
            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 = j - g j j - g j g cnt += 1 cnt 1 A[j+g] = v A[j+g] A j+g j g v return [cnt, A] [cnt, A] cnt A A A n n g g cnt cnt def shellSort(A, n):
    cnt = 0
    a = 1
    G = []
    while a <= n:
        G.append(a)
        a = 3*a + 1
    m = len(G)
    G = G[::-1]
    for i in range(0, m):
        cnt, A = insertionSort(A, n, G[i], cnt)
    return [m, G, cnt, A]
         shellSort cnt = 0 cnt 0 a = 1 a 1 G = [] G [] while a <= n:
        G.append(a)
        a = 3*a + 1
     a <= n a n G.append(a) G.append G append a a = 3*a + 1 a 3*a + 1 3*a 3 a 1 m = len(G) m len(G) len G G = G[::-1] G G[::-1] G ::-1 -1 for i in range(0, m):
        cnt, A = insertionSort(A, n, G[i], cnt)
     i range(0, m) range 0 m cnt, A = insertionSort(A, n, G[i], cnt) cnt insertionSort(A, n, G[i], cnt) insertionSort A n G[i] G i cnt A return [m, G, cnt, A] [m, G, cnt, A] m G cnt A A A n n if __name__ == "__main__":
    n = int(input())
    A = [int(input()) for _ in range(n)]
    m, G, cnt, A = shellSort(A, n)
    print(m)
    print(*G)
    print(cnt)
    for i in A:
        print(i) __name__ == "__main__" __name__ "__main__" 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, cnt, A = shellSort(A, n) m shellSort(A, n) shellSort A n G cnt A print(m) print m print(*G) print *G G print(cnt) print cnt for i in A:
        print(i) i A print(i) print i m, G, cnt, A = shellSort(A, n) shellSort(A, n) m G, cnt, A = shellSort(A, n) shellSort(A, n) G def shellSort(A, n):
    cnt = 0
    a = 1
    G = []
    while a <= n:
        G.append(a)
        a = 3*a + 1
    m = len(G)
    G = G[::-1]
    for i in range(0, m):
        cnt, A = insertionSort(A, n, G[i], cnt)
    return [m, G, cnt, A]
         def shellSort(A, n):
    cnt = 0
    a = 1
    G = []
    while a <= n:
        G.append(a)
        a = 3*a + 1
    m = len(G)
    G = G[::-1]
    for i in range(0, m):
        cnt, A = insertionSort(A, n, G[i], cnt)
    return [m, G, cnt, A]
         shellSort A = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] A cnt, A = shellSort(A, n) shellSort(A, n) cnt n = int(input()) int(input()) n A = shellSort(A, n) shellSort(A, n) A def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return [cnt, A] def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return [cnt, A] insertionSort
def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return [cnt, A]

def shellSort(A, n):
    cnt = 0
    a = 1
    G = []
    while a <= n:
        G.append(a)
        a = 3*a + 1
    m = len(G)
    G = G[::-1]
    for i in range(0, m):
        cnt, A = insertionSort(A, n, G[i], cnt)
    return [m, G, cnt, A]
        
if __name__ == "__main__":
    n = int(input())
    A = [int(input()) for _ in range(n)]
    m, G, cnt, A = shellSort(A, n)
    print(m)
    print(*G)
    print(cnt)
    for i in A:
        print(i)
