import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n = I()
    A = [I() for _ in range(n)]

    def insertionSort(A, n, g):
        cnt = 0
        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 cnt

    # shellSort(A, n)
    cnt = [0]

    G = []
    h = 1
    while h<=n:
        G.append(h)
        h = 3*h+1
    G = list(reversed(G))
    m = len(G)

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

    print(m)
    print(*G)
    print(cnt[0])
    for i in A:
        print(i)

if __name__ == '__main__':
    resolve() import sys sys input = lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 INF = 10**10 INF 10**10 10 10 def I(): return int(input()) I def F(): return float(input()) F def SS(): return input() SS int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x def LI(): return [int(x) for x in input().split()] LI int(x)-1 for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x)-1 int(x) int x 1 def LI_(): return [int(x)-1 for x in input().split()] LI_ float(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() float(x) float x def LF(): return [float(x) for x in input().split()] LF def LSS(): return input().split() LSS def resolve():
    n = I()
    A = [I() for _ in range(n)]

    def insertionSort(A, n, g):
        cnt = 0
        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 cnt

    # shellSort(A, n)
    cnt = [0]

    G = []
    h = 1
    while h<=n:
        G.append(h)
        h = 3*h+1
    G = list(reversed(G))
    m = len(G)

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

    print(m)
    print(*G)
    print(cnt[0])
    for i in A:
        print(i) resolve n = I() n I() I I() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) I() I A = [I() for _ in range(n)] A [I() for _ in range(n)] def insertionSort(A, n, g):
        cnt = 0
        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 cnt

    # shellSort(A, n)
     insertionSort cnt = 0 cnt 0 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 cnt cnt A A n n g g cnt = [0] cnt [0] 0 G = [] G [] h = 1 h 1 while h<=n:
        G.append(h)
        h = 3*h+1
     h<=n h n G.append(h) G.append G append h h = 3*h+1 h 3*h+1 3*h 3 h 1 G = list(reversed(G)) G list(reversed(G)) list reversed(G) reversed G m = len(G) m len(G) len G for i in range(m):
        cnt[0] += insertionSort(A, n, G[i])

     i range(m) range m cnt[0] += insertionSort(A, n, G[i]) cnt[0] cnt 0 insertionSort(A, n, G[i]) insertionSort A n G[i] G i print(m) print m print(*G) print *G G print(cnt[0]) print cnt[0] cnt 0 for i in A:
        print(i) i A print(i) print i if __name__ == '__main__':
    resolve() __name__ == '__main__' __name__ '__main__' resolve() resolve def I(): return int(input()) def I(): return int(input()) I INF = 10**10 10**10 INF input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input def LF(): return [float(x) for x in input().split()] def LF(): return [float(x) for x in input().split()] LF def LI_(): return [int(x)-1 for x in input().split()] def LI_(): return [int(x)-1 for x in input().split()] LI_ def LSS(): return input().split() def LSS(): return input().split() LSS def SS(): return input() def SS(): return input() SS def F(): return float(input()) def F(): return float(input()) F def LI(): return [int(x) for x in input().split()] def LI(): return [int(x) for x in input().split()] LI def resolve():
    n = I()
    A = [I() for _ in range(n)]

    def insertionSort(A, n, g):
        cnt = 0
        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 cnt

    # shellSort(A, n)
    cnt = [0]

    G = []
    h = 1
    while h<=n:
        G.append(h)
        h = 3*h+1
    G = list(reversed(G))
    m = len(G)

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

    print(m)
    print(*G)
    print(cnt[0])
    for i in A:
        print(i) def resolve():
    n = I()
    A = [I() for _ in range(n)]

    def insertionSort(A, n, g):
        cnt = 0
        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 cnt

    # shellSort(A, n)
    cnt = [0]

    G = []
    h = 1
    while h<=n:
        G.append(h)
        h = 3*h+1
    G = list(reversed(G))
    m = len(G)

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

    print(m)
    print(*G)
    print(cnt[0])
    for i in A:
        print(i) resolve
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n = I()
    A = [I() for _ in range(n)]

    def insertionSort(A, n, g):
        cnt = 0
        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 cnt

    # shellSort(A, n)
    cnt = [0]

    G = []
    h = 1
    while h<=n:
        G.append(h)
        h = 3*h+1
    G = list(reversed(G))
    m = len(G)

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

    print(m)
    print(*G)
    print(cnt[0])
    for i in A:
        print(i)

if __name__ == '__main__':
    resolve()
