#Shell sort
def insertionSort(A, n, g, count):
    Acopy = A.copy()
    for i in range(g, n):
        v = Acopy[i]
        j = i - g
        while (j >= 0) and (Acopy[j] > v):
            Acopy[j + g] = Acopy[j]
            j = j - g
            count += 1
        Acopy[j + g] = v
    return Acopy, count

def shellSort(A, n):
    #Gを作成
    G = [1]
    h = 4
    while h < n:
        G.append(h)
        h = 3 * h + 1
    Gr = G.copy()
    Gr.reverse()
    count = 0
    #Gの各要素を使ってSort
    for g in Gr:
        A, count = insertionSort(A, n, g, count)
    return A, Gr, count

n = int(input())
q = 0
A = []
while q < n:
    A.append(int(input()))
    q += 1
A, G, count = shellSort(A, n)
ans = str(len(G)) + '\n' + ' '.join(map(str, G)) + '\n' + str(count) + '\n'
ans += '\n'.join(map(str, A))
print(ans) def insertionSort(A, n, g, count):
    Acopy = A.copy()
    for i in range(g, n):
        v = Acopy[i]
        j = i - g
        while (j >= 0) and (Acopy[j] > v):
            Acopy[j + g] = Acopy[j]
            j = j - g
            count += 1
        Acopy[j + g] = v
    return Acopy, count insertionSort Acopy = A.copy() Acopy A.copy() A.copy A copy for i in range(g, n):
        v = Acopy[i]
        j = i - g
        while (j >= 0) and (Acopy[j] > v):
            Acopy[j + g] = Acopy[j]
            j = j - g
            count += 1
        Acopy[j + g] = v
     i range(g, n) range g n v = Acopy[i] v Acopy[i] Acopy i j = i - g j i - g i g while (j >= 0) and (Acopy[j] > v):
            Acopy[j + g] = Acopy[j]
            j = j - g
            count += 1
         (j >= 0) and (Acopy[j] > v) j >= 0 j 0 Acopy[j] > v Acopy[j] Acopy j v Acopy[j + g] = Acopy[j] Acopy[j + g] Acopy j + g j g Acopy[j] Acopy j j = j - g j j - g j g count += 1 count 1 Acopy[j + g] = v Acopy[j + g] Acopy j + g j g v return Acopy, count return Acopy, count Acopy count A A n n g g count count def shellSort(A, n):
    #Gを作成
    G = [1]
    h = 4
    while h < n:
        G.append(h)
        h = 3 * h + 1
    Gr = G.copy()
    Gr.reverse()
    count = 0
    #Gの各要素を使ってSort
    for g in Gr:
        A, count = insertionSort(A, n, g, count)
    return A, Gr, count shellSort G = [1] G [1] 1 h = 4 h 4 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 Gr = G.copy() Gr G.copy() G.copy G copy Gr.reverse() Gr.reverse Gr reverse count = 0 count 0 for g in Gr:
        A, count = insertionSort(A, n, g, count)
     g Gr A, count = insertionSort(A, n, g, count) A insertionSort(A, n, g, count) insertionSort A n g count count return A, Gr, count return A, Gr, count A Gr count A A n n n = int(input()) n int(input()) int input() input q = 0 q 0 A = [] A [] while q < n:
    A.append(int(input()))
    q += 1 q < n q n A.append(int(input())) A.append A append int(input()) int input() input q += 1 q 1 A, G, count = shellSort(A, n) A shellSort(A, n) shellSort A n G count ans = str(len(G)) + '\n' + ' '.join(map(str, G)) + '\n' + str(count) + '\n' ans str(len(G)) + '\n' + ' '.join(map(str, G)) + '\n' + str(count) + '\n' str(len(G)) + '\n' + ' '.join(map(str, G)) + '\n' + str(count) str(len(G)) + '\n' + ' '.join(map(str, G)) + '\n' str(len(G)) + '\n' + ' '.join(map(str, G)) str(len(G)) + '\n' str(len(G)) str len(G) len G '\n' ' '.join(map(str, G)) ' '.join ' ' join map(str, G) map str G '\n' str(count) str count '\n' ans += '\n'.join(map(str, A)) ans '\n'.join(map(str, A)) '\n'.join '\n' join map(str, A) map str A print(ans) print ans ans = str(len(G)) + '\n' + ' '.join(map(str, G)) + '\n' + str(count) + '\n' str(len(G)) + '\n' + ' '.join(map(str, G)) + '\n' + str(count) + '\n' ans ans += '\n'.join(map(str, A)) '\n'.join(map(str, A)) ans G, count = shellSort(A, n) shellSort(A, n) G q = 0 0 q A = [] [] A def shellSort(A, n):
    #Gを作成
    G = [1]
    h = 4
    while h < n:
        G.append(h)
        h = 3 * h + 1
    Gr = G.copy()
    Gr.reverse()
    count = 0
    #Gの各要素を使ってSort
    for g in Gr:
        A, count = insertionSort(A, n, g, count)
    return A, Gr, count def shellSort(A, n):
    #Gを作成
    G = [1]
    h = 4
    while h < n:
        G.append(h)
        h = 3 * h + 1
    Gr = G.copy()
    Gr.reverse()
    count = 0
    #Gの各要素を使ってSort
    for g in Gr:
        A, count = insertionSort(A, n, g, count)
    return A, Gr, count shellSort A, G, count = shellSort(A, n) shellSort(A, n) A count = shellSort(A, n) shellSort(A, n) count def insertionSort(A, n, g, count):
    Acopy = A.copy()
    for i in range(g, n):
        v = Acopy[i]
        j = i - g
        while (j >= 0) and (Acopy[j] > v):
            Acopy[j + g] = Acopy[j]
            j = j - g
            count += 1
        Acopy[j + g] = v
    return Acopy, count def insertionSort(A, n, g, count):
    Acopy = A.copy()
    for i in range(g, n):
        v = Acopy[i]
        j = i - g
        while (j >= 0) and (Acopy[j] > v):
            Acopy[j + g] = Acopy[j]
            j = j - g
            count += 1
        Acopy[j + g] = v
    return Acopy, count insertionSort n = int(input()) int(input()) n q += 1 1 q
#Shell sort
def insertionSort(A, n, g, count):
    Acopy = A.copy()
    for i in range(g, n):
        v = Acopy[i]
        j = i - g
        while (j >= 0) and (Acopy[j] > v):
            Acopy[j + g] = Acopy[j]
            j = j - g
            count += 1
        Acopy[j + g] = v
    return Acopy, count

def shellSort(A, n):
    #Gを作成
    G = [1]
    h = 4
    while h < n:
        G.append(h)
        h = 3 * h + 1
    Gr = G.copy()
    Gr.reverse()
    count = 0
    #Gの各要素を使ってSort
    for g in Gr:
        A, count = insertionSort(A, n, g, count)
    return A, Gr, count

n = int(input())
q = 0
A = []
while q < n:
    A.append(int(input()))
    q += 1
A, G, count = shellSort(A, n)
ans = str(len(G)) + '\n' + ' '.join(map(str, G)) + '\n' + str(count) + '\n'
ans += '\n'.join(map(str, A))
print(ans)
