import sys

def insertionSort(A,N,g):
    cnt = 0
    for i in range(g,len(A)):
        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
    return cnt


def shellSort(A,N):
    cnt = 0
    G = [(3**i-1)//2 for i in range(1,17) if ((3**i-1)//2) <= N]
    m = len(G)
    for i in reversed(range(m)):
        cnt += insertionSort(A,N,G[i])

    print(len(G))
    print(" ".join(map(str,reversed(G))))
    print(cnt)
    print("\n".join(map(str,A)))


N = int(input())
#lst = list(map(int, [input() for i in range(N)]))
lst = [int(l) for l in sys.stdin.readlines()]
#lst = [i for i in range(100000)]
#reversed(lst)
shellSort(lst,N)
 import sys sys def insertionSort(A,N,g):
    cnt = 0
    for i in range(g,len(A)):
        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
    return cnt insertionSort cnt = 0 cnt 0 for i in range(g,len(A)):
        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,len(A)) range g len(A) len A 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 return cnt cnt A A N N g g def shellSort(A,N):
    cnt = 0
    G = [(3**i-1)//2 for i in range(1,17) if ((3**i-1)//2) <= N]
    m = len(G)
    for i in reversed(range(m)):
        cnt += insertionSort(A,N,G[i])

    print(len(G))
    print(" ".join(map(str,reversed(G))))
    print(cnt)
    print("\n".join(map(str,A))) shellSort cnt = 0 cnt 0 (3**i-1)//2 for i in range(1,17) if ((3**i-1)//2) <= N for i in range(1,17) if ((3**i-1)//2) <= N i range(1,17) range 1 17 ((3**i-1)//2) <= N (3**i-1)//2 3**i-1 3**i 3 i 1 2 N if ((3**i-1)//2) <= N (3**i-1)//2 3**i-1 3**i 3 i 1 2 G = [(3**i-1)//2 for i in range(1,17) if ((3**i-1)//2) <= N] G [(3**i-1)//2 for i in range(1,17) if ((3**i-1)//2) <= N] m = len(G) m len(G) len G for i in reversed(range(m)):
        cnt += insertionSort(A,N,G[i])

     i reversed(range(m)) reversed range(m) range m cnt += insertionSort(A,N,G[i]) cnt insertionSort(A,N,G[i]) insertionSort A N G[i] G i print(len(G)) print len(G) len G print(" ".join(map(str,reversed(G)))) print " ".join(map(str,reversed(G))) " ".join " " join map(str,reversed(G)) map str reversed(G) reversed G print(cnt) print cnt print("\n".join(map(str,A))) print "\n".join(map(str,A)) "\n".join "\n" join map(str,A) map str A A A N N N = int(input()) N int(input()) int input() input int(l) for l in sys.stdin.readlines() for l in sys.stdin.readlines() l sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines for l in sys.stdin.readlines() int(l) int l lst = [int(l) for l in sys.stdin.readlines()] lst [int(l) for l in sys.stdin.readlines()] shellSort(lst,N) shellSort lst N lst = [int(l) for l in sys.stdin.readlines()] [int(l) for l in sys.stdin.readlines()] lst def insertionSort(A,N,g):
    cnt = 0
    for i in range(g,len(A)):
        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
    return cnt def insertionSort(A,N,g):
    cnt = 0
    for i in range(g,len(A)):
        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
    return cnt insertionSort def shellSort(A,N):
    cnt = 0
    G = [(3**i-1)//2 for i in range(1,17) if ((3**i-1)//2) <= N]
    m = len(G)
    for i in reversed(range(m)):
        cnt += insertionSort(A,N,G[i])

    print(len(G))
    print(" ".join(map(str,reversed(G))))
    print(cnt)
    print("\n".join(map(str,A))) def shellSort(A,N):
    cnt = 0
    G = [(3**i-1)//2 for i in range(1,17) if ((3**i-1)//2) <= N]
    m = len(G)
    for i in reversed(range(m)):
        cnt += insertionSort(A,N,G[i])

    print(len(G))
    print(" ".join(map(str,reversed(G))))
    print(cnt)
    print("\n".join(map(str,A))) shellSort N = int(input()) int(input()) N
import sys

def insertionSort(A,N,g):
    cnt = 0
    for i in range(g,len(A)):
        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
    return cnt


def shellSort(A,N):
    cnt = 0
    G = [(3**i-1)//2 for i in range(1,17) if ((3**i-1)//2) <= N]
    m = len(G)
    for i in reversed(range(m)):
        cnt += insertionSort(A,N,G[i])

    print(len(G))
    print(" ".join(map(str,reversed(G))))
    print(cnt)
    print("\n".join(map(str,A)))


N = int(input())
#lst = list(map(int, [input() for i in range(N)]))
lst = [int(l) for l in sys.stdin.readlines()]
#lst = [i for i in range(100000)]
#reversed(lst)
shellSort(lst,N)

