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


def shellSort(A, n):
    cnt = 0

    G = []
    G.append(1)
    for i in range(n):
        tmp = 3 * G[-1] + 1
        if tmp > n:
            break
        else:
            G.append(tmp)
    G.reverse()
    m = len(G)

    print(m)
    print(*G)

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

    print(cnt)


def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))

    shellSort(a, n)

    for i in range(n):
        print(a[i])


if __name__ == '__main__':
    main() 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 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 cnt A A n n g g cnt cnt def shellSort(A, n):
    cnt = 0

    G = []
    G.append(1)
    for i in range(n):
        tmp = 3 * G[-1] + 1
        if tmp > n:
            break
        else:
            G.append(tmp)
    G.reverse()
    m = len(G)

    print(m)
    print(*G)

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

    print(cnt) shellSort cnt = 0 cnt 0 G = [] G [] G.append(1) G.append G append 1 for i in range(n):
        tmp = 3 * G[-1] + 1
        if tmp > n:
            break
        else:
            G.append(tmp)
     i range(n) range n tmp = 3 * G[-1] + 1 tmp 3 * G[-1] + 1 3 * G[-1] 3 G[-1] G -1 1 if tmp > n:
            break
        else:
            G.append(tmp)
     tmp > n tmp n break G.append(tmp) G.append G append tmp G.reverse() G.reverse G reverse m = len(G) m len(G) len G print(m) print m print(*G) print *G G for i in range(m):
        cnt = insertionSort(A, n, G[i], cnt)

     i range(m) range m cnt = insertionSort(A, n, G[i], cnt) cnt insertionSort(A, n, G[i], cnt) insertionSort A n G[i] G i cnt print(cnt) print cnt A A n n def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))

    shellSort(a, n)

    for i in range(n):
        print(a[i]) 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 shellSort(a, n) shellSort a n for i in range(n):
        print(a[i]) i range(n) range n print(a[i]) print a[i] a i if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))

    shellSort(a, n)

    for i in range(n):
        print(a[i]) def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))

    shellSort(a, n)

    for i in range(n):
        print(a[i]) main def shellSort(A, n):
    cnt = 0

    G = []
    G.append(1)
    for i in range(n):
        tmp = 3 * G[-1] + 1
        if tmp > n:
            break
        else:
            G.append(tmp)
    G.reverse()
    m = len(G)

    print(m)
    print(*G)

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

    print(cnt) def shellSort(A, n):
    cnt = 0

    G = []
    G.append(1)
    for i in range(n):
        tmp = 3 * G[-1] + 1
        if tmp > n:
            break
        else:
            G.append(tmp)
    G.reverse()
    m = len(G)

    print(m)
    print(*G)

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

    print(cnt) shellSort 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 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 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


def shellSort(A, n):
    cnt = 0

    G = []
    G.append(1)
    for i in range(n):
        tmp = 3 * G[-1] + 1
        if tmp > n:
            break
        else:
            G.append(tmp)
    G.reverse()
    m = len(G)

    print(m)
    print(*G)

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

    print(cnt)


def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))

    shellSort(a, n)

    for i in range(n):
        print(a[i])


if __name__ == '__main__':
    main()
