def insertionSort(table, g):
    global cnt
    for i in range(g, len(table)):
        v = table[i]
        j = i - g
        while j >= 0 and table[j] > v:
            table[j + g] = table[j]
            j = j - g
            cnt += 1
        table[j + g] = v


def shellSort(table):
    gap = [1]
    while gap[0] * 3 + 1 < len(table):
        gap.insert(0, (gap[0] * 3 + 1))
    for g in gap:
        insertionSort(table, g)
    return gap


n = int(input())
table = []
cnt =0
for i in range(n):
    table.append(int(input()))
gap = shellSort(table)
print(len(gap))
print(' '.join(map(str, gap)))
print(cnt)
print('\n'.join(map(str, table)))
 def insertionSort(table, g):
    global cnt
    for i in range(g, len(table)):
        v = table[i]
        j = i - g
        while j >= 0 and table[j] > v:
            table[j + g] = table[j]
            j = j - g
            cnt += 1
        table[j + g] = v insertionSort global cnt for i in range(g, len(table)):
        v = table[i]
        j = i - g
        while j >= 0 and table[j] > v:
            table[j + g] = table[j]
            j = j - g
            cnt += 1
        table[j + g] = v i range(g, len(table)) range g len(table) len table v = table[i] v table[i] table i j = i - g j i - g i g while j >= 0 and table[j] > v:
            table[j + g] = table[j]
            j = j - g
            cnt += 1
         j >= 0 and table[j] > v j >= 0 j 0 table[j] > v table[j] table j v table[j + g] = table[j] table[j + g] table j + g j g table[j] table j j = j - g j j - g j g cnt += 1 cnt 1 table[j + g] = v table[j + g] table j + g j g v table table g g def shellSort(table):
    gap = [1]
    while gap[0] * 3 + 1 < len(table):
        gap.insert(0, (gap[0] * 3 + 1))
    for g in gap:
        insertionSort(table, g)
    return gap shellSort gap = [1] gap [1] 1 while gap[0] * 3 + 1 < len(table):
        gap.insert(0, (gap[0] * 3 + 1))
     gap[0] * 3 + 1 < len(table) gap[0] * 3 + 1 gap[0] * 3 gap[0] gap 0 3 1 len(table) len table gap.insert(0, (gap[0] * 3 + 1)) gap.insert gap insert 0 gap[0] * 3 + 1 gap[0] * 3 gap[0] gap 0 3 1 for g in gap:
        insertionSort(table, g)
     g gap insertionSort(table, g) insertionSort table g return gap gap table table n = int(input()) n int(input()) int input() input table = [] table [] cnt =0 cnt 0 for i in range(n):
    table.append(int(input())) i range(n) range n table.append(int(input())) table.append table append int(input()) int input() input gap = shellSort(table) gap shellSort(table) shellSort table print(len(gap)) print len(gap) len gap print(' '.join(map(str, gap))) print ' '.join(map(str, gap)) ' '.join ' ' join map(str, gap) map str gap print(cnt) print cnt print('\n'.join(map(str, table))) print '\n'.join(map(str, table)) '\n'.join '\n' join map(str, table) map str table def shellSort(table):
    gap = [1]
    while gap[0] * 3 + 1 < len(table):
        gap.insert(0, (gap[0] * 3 + 1))
    for g in gap:
        insertionSort(table, g)
    return gap def shellSort(table):
    gap = [1]
    while gap[0] * 3 + 1 < len(table):
        gap.insert(0, (gap[0] * 3 + 1))
    for g in gap:
        insertionSort(table, g)
    return gap shellSort table = [] [] table def insertionSort(table, g):
    global cnt
    for i in range(g, len(table)):
        v = table[i]
        j = i - g
        while j >= 0 and table[j] > v:
            table[j + g] = table[j]
            j = j - g
            cnt += 1
        table[j + g] = v def insertionSort(table, g):
    global cnt
    for i in range(g, len(table)):
        v = table[i]
        j = i - g
        while j >= 0 and table[j] > v:
            table[j + g] = table[j]
            j = j - g
            cnt += 1
        table[j + g] = v insertionSort gap = shellSort(table) shellSort(table) gap cnt =0 0 cnt n = int(input()) int(input()) n
def insertionSort(table, g):
    global cnt
    for i in range(g, len(table)):
        v = table[i]
        j = i - g
        while j >= 0 and table[j] > v:
            table[j + g] = table[j]
            j = j - g
            cnt += 1
        table[j + g] = v


def shellSort(table):
    gap = [1]
    while gap[0] * 3 + 1 < len(table):
        gap.insert(0, (gap[0] * 3 + 1))
    for g in gap:
        insertionSort(table, g)
    return gap


n = int(input())
table = []
cnt =0
for i in range(n):
    table.append(int(input()))
gap = shellSort(table)
print(len(gap))
print(' '.join(map(str, gap)))
print(cnt)
print('\n'.join(map(str, table)))

