def insertionSort(A, n, g, cnt):
    i = g
    while n-1 >= i:
        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 += 1
    return cnt


def shellSort(A, n, cnt):
    G = []
    e = 1
    while len(A) >= e:
        G.append(e)
        e = 3 * e + 1
    G.reverse()
    m = len(G)

    print(m)
    i = 0
    for g in G:
        if i != m-1:
            print("{} ".format(g), end="")
        elif i == m-1:
            print(g)
        i += 1

    for g in G:
        cnt = insertionSort(A, n, g, cnt)

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

    return cnt


n = int(input())
a = []
cnt = 0
for _ in range(n):
    a.append(int(input()))

cnt = shellSort(a, n, cnt)
 def insertionSort(A, n, g, cnt):
    i = g
    while n-1 >= i:
        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 += 1
    return cnt insertionSort i = g i g while n-1 >= i:
        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 += 1
     n-1 >= i n-1 n 1 i 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 i += 1 i 1 return cnt cnt A A n n g g cnt cnt def shellSort(A, n, cnt):
    G = []
    e = 1
    while len(A) >= e:
        G.append(e)
        e = 3 * e + 1
    G.reverse()
    m = len(G)

    print(m)
    i = 0
    for g in G:
        if i != m-1:
            print("{} ".format(g), end="")
        elif i == m-1:
            print(g)
        i += 1

    for g in G:
        cnt = insertionSort(A, n, g, cnt)

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

    return cnt shellSort G = [] G [] e = 1 e 1 while len(A) >= e:
        G.append(e)
        e = 3 * e + 1
     len(A) >= e len(A) len A e G.append(e) G.append G append e e = 3 * e + 1 e 3 * e + 1 3 * e 3 e 1 G.reverse() G.reverse G reverse m = len(G) m len(G) len G print(m) print m i = 0 i 0 for g in G:
        if i != m-1:
            print("{} ".format(g), end="")
        elif i == m-1:
            print(g)
        i += 1

     g G if i != m-1:
            print("{} ".format(g), end="")
        elif i == m-1:
            print(g)
         i != m-1 i m-1 m 1 print("{} ".format(g), end="") print "{} ".format(g) "{} ".format "{} " format g end="" end "" elif i == m-1:
            print(g)
         i == m-1 i m-1 m 1 print(g) print g i += 1 i 1 for g in G:
        cnt = insertionSort(A, n, g, cnt)

     g G cnt = insertionSort(A, n, g, cnt) cnt insertionSort(A, n, g, cnt) insertionSort A n g cnt print(cnt) print cnt for a in A:
        print(a)

     a A print(a) print a return cnt cnt A A n n cnt cnt n = int(input()) n int(input()) int input() input a = [] a [] cnt = 0 cnt 0 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 cnt = shellSort(a, n, cnt) cnt shellSort(a, n, cnt) shellSort a n cnt def insertionSort(A, n, g, cnt):
    i = g
    while n-1 >= i:
        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 += 1
    return cnt def insertionSort(A, n, g, cnt):
    i = g
    while n-1 >= i:
        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 += 1
    return cnt insertionSort cnt = shellSort(a, n, cnt) shellSort(a, n, cnt) cnt cnt = 0 0 cnt n = int(input()) int(input()) n def shellSort(A, n, cnt):
    G = []
    e = 1
    while len(A) >= e:
        G.append(e)
        e = 3 * e + 1
    G.reverse()
    m = len(G)

    print(m)
    i = 0
    for g in G:
        if i != m-1:
            print("{} ".format(g), end="")
        elif i == m-1:
            print(g)
        i += 1

    for g in G:
        cnt = insertionSort(A, n, g, cnt)

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

    return cnt def shellSort(A, n, cnt):
    G = []
    e = 1
    while len(A) >= e:
        G.append(e)
        e = 3 * e + 1
    G.reverse()
    m = len(G)

    print(m)
    i = 0
    for g in G:
        if i != m-1:
            print("{} ".format(g), end="")
        elif i == m-1:
            print(g)
        i += 1

    for g in G:
        cnt = insertionSort(A, n, g, cnt)

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

    return cnt shellSort a = [] [] a
def insertionSort(A, n, g, cnt):
    i = g
    while n-1 >= i:
        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 += 1
    return cnt


def shellSort(A, n, cnt):
    G = []
    e = 1
    while len(A) >= e:
        G.append(e)
        e = 3 * e + 1
    G.reverse()
    m = len(G)

    print(m)
    i = 0
    for g in G:
        if i != m-1:
            print("{} ".format(g), end="")
        elif i == m-1:
            print(g)
        i += 1

    for g in G:
        cnt = insertionSort(A, n, g, cnt)

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

    return cnt


n = int(input())
a = []
cnt = 0
for _ in range(n):
    a.append(int(input()))

cnt = shellSort(a, n, cnt)

