def insetionSort(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
    return A

def shellSort(b,p):
    global cnt
    t = 1
    G = [1]
    while t*3+1 < p:
        t = t*3 +1
        G.append(t)
    G.reverse()
    m = len(G)
    for i in range(0,m):
        b = insetionSort(b,p,G[i])
    print(m)
    print(" ".join(map(str,G)))
    print(cnt)
    for t in b:
        print(t)

num = int(input())
lister = [int(input()) for s in range(num)]
cnt = 0
shellSort(lister,num) def insetionSort(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
    return A insetionSort 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 return A A A A n n g g def shellSort(b,p):
    global cnt
    t = 1
    G = [1]
    while t*3+1 < p:
        t = t*3 +1
        G.append(t)
    G.reverse()
    m = len(G)
    for i in range(0,m):
        b = insetionSort(b,p,G[i])
    print(m)
    print(" ".join(map(str,G)))
    print(cnt)
    for t in b:
        print(t) shellSort global cnt t = 1 t 1 G = [1] G [1] 1 while t*3+1 < p:
        t = t*3 +1
        G.append(t)
     t*3+1 < p t*3+1 t*3 t 3 1 p t = t*3 +1 t t*3 +1 t*3 t 3 1 G.append(t) G.append G append t G.reverse() G.reverse G reverse m = len(G) m len(G) len G for i in range(0,m):
        b = insetionSort(b,p,G[i])
     i range(0,m) range 0 m b = insetionSort(b,p,G[i]) b insetionSort(b,p,G[i]) insetionSort b p G[i] G i print(m) print m print(" ".join(map(str,G))) print " ".join(map(str,G)) " ".join " " join map(str,G) map str G print(cnt) print cnt for t in b:
        print(t) t b print(t) print t b b p p num = int(input()) num int(input()) int input() input int(input()) for s in range(num) for s in range(num) s range(num) range num for s in range(num) int(input()) int input() input lister = [int(input()) for s in range(num)] lister [int(input()) for s in range(num)] cnt = 0 cnt 0 shellSort(lister,num) shellSort lister num num = int(input()) int(input()) num def insetionSort(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
    return A def insetionSort(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
    return A insetionSort def shellSort(b,p):
    global cnt
    t = 1
    G = [1]
    while t*3+1 < p:
        t = t*3 +1
        G.append(t)
    G.reverse()
    m = len(G)
    for i in range(0,m):
        b = insetionSort(b,p,G[i])
    print(m)
    print(" ".join(map(str,G)))
    print(cnt)
    for t in b:
        print(t) def shellSort(b,p):
    global cnt
    t = 1
    G = [1]
    while t*3+1 < p:
        t = t*3 +1
        G.append(t)
    G.reverse()
    m = len(G)
    for i in range(0,m):
        b = insetionSort(b,p,G[i])
    print(m)
    print(" ".join(map(str,G)))
    print(cnt)
    for t in b:
        print(t) shellSort cnt = 0 0 cnt lister = [int(input()) for s in range(num)] [int(input()) for s in range(num)] lister
def insetionSort(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
    return A

def shellSort(b,p):
    global cnt
    t = 1
    G = [1]
    while t*3+1 < p:
        t = t*3 +1
        G.append(t)
    G.reverse()
    m = len(G)
    for i in range(0,m):
        b = insetionSort(b,p,G[i])
    print(m)
    print(" ".join(map(str,G)))
    print(cnt)
    for t in b:
        print(t)

num = int(input())
lister = [int(input()) for s in range(num)]
cnt = 0
shellSort(lister,num)
