cnt = 0
def InsertionSort(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

def ShellSort(A, n):
    G = list()
    gn = 1 

    while gn <= n:
        G.append(gn)
        gn = 3 * gn + 1

    m = len(G)
    G.reverse()

    for g in G:
        InsertionSort(A, len(A), g)

    return G

def Main():
    N = int(input())
    A = list()

    for n in range(N):
        A.append(int(input()))

    G = ShellSort(A, len(A))

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

Main() cnt = 0 cnt 0 def InsertionSort(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 InsertionSort 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 A A n n g g def ShellSort(A, n):
    G = list()
    gn = 1 

    while gn <= n:
        G.append(gn)
        gn = 3 * gn + 1

    m = len(G)
    G.reverse()

    for g in G:
        InsertionSort(A, len(A), g)

    return G ShellSort G = list() G list() list gn = 1 gn 1 while gn <= n:
        G.append(gn)
        gn = 3 * gn + 1

     gn <= n gn n G.append(gn) G.append G append gn gn = 3 * gn + 1 gn 3 * gn + 1 3 * gn 3 gn 1 m = len(G) m len(G) len G G.reverse() G.reverse G reverse for g in G:
        InsertionSort(A, len(A), g)

     g G InsertionSort(A, len(A), g) InsertionSort A len(A) len A g return G G A A n n def Main():
    N = int(input())
    A = list()

    for n in range(N):
        A.append(int(input()))

    G = ShellSort(A, len(A))

    print(len(G))
    print(*G)
    print(cnt)
    print("\n".join(map(str, A))) Main N = int(input()) N int(input()) int input() input A = list() A list() list for n in range(N):
        A.append(int(input()))

     n range(N) range N A.append(int(input())) A.append A append int(input()) int input() input G = ShellSort(A, len(A)) G ShellSort(A, len(A)) ShellSort A len(A) len A print(len(G)) print len(G) len G print(*G) print *G 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 Main() Main def InsertionSort(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 def InsertionSort(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 InsertionSort def ShellSort(A, n):
    G = list()
    gn = 1 

    while gn <= n:
        G.append(gn)
        gn = 3 * gn + 1

    m = len(G)
    G.reverse()

    for g in G:
        InsertionSort(A, len(A), g)

    return G def ShellSort(A, n):
    G = list()
    gn = 1 

    while gn <= n:
        G.append(gn)
        gn = 3 * gn + 1

    m = len(G)
    G.reverse()

    for g in G:
        InsertionSort(A, len(A), g)

    return G ShellSort def Main():
    N = int(input())
    A = list()

    for n in range(N):
        A.append(int(input()))

    G = ShellSort(A, len(A))

    print(len(G))
    print(*G)
    print(cnt)
    print("\n".join(map(str, A))) def Main():
    N = int(input())
    A = list()

    for n in range(N):
        A.append(int(input()))

    G = ShellSort(A, len(A))

    print(len(G))
    print(*G)
    print(cnt)
    print("\n".join(map(str, A))) Main cnt = 0 0 cnt
cnt = 0
def InsertionSort(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

def ShellSort(A, n):
    G = list()
    gn = 1 

    while gn <= n:
        G.append(gn)
        gn = 3 * gn + 1

    m = len(G)
    G.reverse()

    for g in G:
        InsertionSort(A, len(A), g)

    return G

def Main():
    N = int(input())
    A = list()

    for n in range(N):
        A.append(int(input()))

    G = ShellSort(A, len(A))

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

Main()
