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


def shellSort(A, n):
    global m
    global G

    h = 1
    while True:
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    m =len(G)

    for i in range(m):
        insertionSort(n, A, G[i])


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

    h = 1
    while True:
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    m =len(G)

    for i in range(m):
        insertionSort(n, A, G[i]) shellSort global m global G h = 1 h 1 while True:
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1
     True if h > n:
            break
         h > n h n break 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):
        insertionSort(n, A, G[i]) i range(m) range m insertionSort(n, A, G[i]) insertionSort n A G[i] G i A A n n if __name__ == "__main__":
    n = int(input())
    A = [int(input()) for i in range(n)]
    G = []
    m = 0
    cnt = 0
    shellSort(A, n)
    print(m)
    print(*G)
    print(cnt)
    for i in range(n):
        print(A[i]) __name__ == "__main__" __name__ "__main__" n = int(input()) n int(input()) int input() input int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input A = [int(input()) for i in range(n)] A [int(input()) for i in range(n)] G = [] G [] m = 0 m 0 cnt = 0 cnt 0 shellSort(A, n) shellSort A n print(m) print m print(*G) print *G G 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 def shellSort(A, n):
    global m
    global G

    h = 1
    while True:
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    m =len(G)

    for i in range(m):
        insertionSort(n, A, G[i]) def shellSort(A, n):
    global m
    global G

    h = 1
    while True:
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    m =len(G)

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


def shellSort(A, n):
    global m
    global G

    h = 1
    while True:
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1
    G.reverse()
    m =len(G)

    for i in range(m):
        insertionSort(n, A, G[i])


if __name__ == "__main__":
    n = int(input())
    A = [int(input()) for i in range(n)]
    G = []
    m = 0
    cnt = 0
    shellSort(A, n)
    print(m)
    print(*G)
    print(cnt)
    for i in range(n):
        print(A[i])