cnt = 0

def insertionsort(A,n,g):
    global 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 -= g
            cnt += 1
        A[j+g] = v

def shellsort(A,n):
    h = 1
    G = []
    while h <= len(A):
        G.append(h)
        h = h*3+1
    G.reverse()
    m = len(G)
    for i in range(m):
        insertionsort(A,n,G[i])
    return m,G
def main():
    n = int(input())
    A = []
    for _ in range(n):
        A.append(int(input()))
    m,G = shellsort(A,n)
    ##print("-----------")
    print(m)
    print(*G)
    print(cnt)
    for i in A:
        print(i)

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

def insertionsort(A,n,g):
    global 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 -= g
            cnt += 1
        A[j+g] = v

def shellsort(A,n):
    h = 1
    G = []
    while h <= len(A):
        G.append(h)
        h = h*3+1
    G.reverse()
    m = len(G)
    for i in range(m):
        insertionsort(A,n,G[i])
    return m,G
def main():
    n = int(input())
    A = []
    for _ in range(n):
        A.append(int(input()))
    m,G = shellsort(A,n)
    ##print("-----------")
    print(m)
    print(*G)
    print(cnt)
    for i in A:
        print(i)

if __name__ == "__main__":
    main()
