import random

# n = 10
# A = [random.randint(1, 100) for i in range(20)]
n = int(input())
A = [int(input()) for i in range(n)]
cnt = 0

def insertion_sort(list, step):
    n = len(list)
    for i in range(step, n):
        temp = list[i]
        j = i
        while j >= step and list[j - step] > temp:
            list[j] = list[j - step]
            j -= step
            global cnt
            cnt += 1
        list[j] = temp
    return list

def shell_sort(list):
    n = len(list)
    
    G = []
    step = 1
    while step <= n:
        G.append(step)
        step = 3*step + 1
    print(len(G))
    for g in sorted(G, reverse=True):
        print(g, end=' ')
    print('\n', end='')

    for i in sorted(range(len(G)), reverse=True):
        list = insertion_sort(list, G[i])
    return list

shell_sort(A)
print(cnt)

for i in A:
    print(i, end='\n') import random random n = int(input()) n int(input()) int input() input int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input A = [int(input()) for i in range(n)] A [int(input()) for i in range(n)] cnt = 0 cnt 0 def insertion_sort(list, step):
    n = len(list)
    for i in range(step, n):
        temp = list[i]
        j = i
        while j >= step and list[j - step] > temp:
            list[j] = list[j - step]
            j -= step
            global cnt
            cnt += 1
        list[j] = temp
    return list insertion_sort n = len(list) n len(list) len list for i in range(step, n):
        temp = list[i]
        j = i
        while j >= step and list[j - step] > temp:
            list[j] = list[j - step]
            j -= step
            global cnt
            cnt += 1
        list[j] = temp
     i range(step, n) range step n temp = list[i] temp list[i] list i j = i j i while j >= step and list[j - step] > temp:
            list[j] = list[j - step]
            j -= step
            global cnt
            cnt += 1
         j >= step and list[j - step] > temp j >= step j step list[j - step] > temp list[j - step] list j - step j step temp list[j] = list[j - step] list[j] list j list[j - step] list j - step j step j -= step j step global cnt cnt += 1 cnt 1 list[j] = temp list[j] list j temp return list list list list step step def shell_sort(list):
    n = len(list)
    
    G = []
    step = 1
    while step <= n:
        G.append(step)
        step = 3*step + 1
    print(len(G))
    for g in sorted(G, reverse=True):
        print(g, end=' ')
    print('\n', end='')

    for i in sorted(range(len(G)), reverse=True):
        list = insertion_sort(list, G[i])
    return list shell_sort n = len(list) n len(list) len list G = [] G [] step = 1 step 1 while step <= n:
        G.append(step)
        step = 3*step + 1
     step <= n step n G.append(step) G.append G append step step = 3*step + 1 step 3*step + 1 3*step 3 step 1 print(len(G)) print len(G) len G for g in sorted(G, reverse=True):
        print(g, end=' ')
     g sorted(G, reverse=True) sorted G reverse=True reverse True print(g, end=' ') print g end=' ' end ' ' print('\n', end='') print '\n' end='' end '' for i in sorted(range(len(G)), reverse=True):
        list = insertion_sort(list, G[i])
     i sorted(range(len(G)), reverse=True) sorted range(len(G)) range len(G) len G reverse=True reverse True list = insertion_sort(list, G[i]) list insertion_sort(list, G[i]) insertion_sort list G[i] G i return list list list list shell_sort(A) shell_sort A print(cnt) print cnt for i in A:
    print(i, end='\n') i A print(i, end='\n') print i end='\n' end '\n' n = int(input()) int(input()) n cnt = 0 0 cnt def insertion_sort(list, step):
    n = len(list)
    for i in range(step, n):
        temp = list[i]
        j = i
        while j >= step and list[j - step] > temp:
            list[j] = list[j - step]
            j -= step
            global cnt
            cnt += 1
        list[j] = temp
    return list def insertion_sort(list, step):
    n = len(list)
    for i in range(step, n):
        temp = list[i]
        j = i
        while j >= step and list[j - step] > temp:
            list[j] = list[j - step]
            j -= step
            global cnt
            cnt += 1
        list[j] = temp
    return list insertion_sort def shell_sort(list):
    n = len(list)
    
    G = []
    step = 1
    while step <= n:
        G.append(step)
        step = 3*step + 1
    print(len(G))
    for g in sorted(G, reverse=True):
        print(g, end=' ')
    print('\n', end='')

    for i in sorted(range(len(G)), reverse=True):
        list = insertion_sort(list, G[i])
    return list def shell_sort(list):
    n = len(list)
    
    G = []
    step = 1
    while step <= n:
        G.append(step)
        step = 3*step + 1
    print(len(G))
    for g in sorted(G, reverse=True):
        print(g, end=' ')
    print('\n', end='')

    for i in sorted(range(len(G)), reverse=True):
        list = insertion_sort(list, G[i])
    return list shell_sort A = [int(input()) for i in range(n)] [int(input()) for i in range(n)] A
import random

# n = 10
# A = [random.randint(1, 100) for i in range(20)]
n = int(input())
A = [int(input()) for i in range(n)]
cnt = 0

def insertion_sort(list, step):
    n = len(list)
    for i in range(step, n):
        temp = list[i]
        j = i
        while j >= step and list[j - step] > temp:
            list[j] = list[j - step]
            j -= step
            global cnt
            cnt += 1
        list[j] = temp
    return list

def shell_sort(list):
    n = len(list)
    
    G = []
    step = 1
    while step <= n:
        G.append(step)
        step = 3*step + 1
    print(len(G))
    for g in sorted(G, reverse=True):
        print(g, end=' ')
    print('\n', end='')

    for i in sorted(range(len(G)), reverse=True):
        list = insertion_sort(list, G[i])
    return list

shell_sort(A)
print(cnt)

for i in A:
    print(i, end='\n')