def insertion_sort(num_list,gap):
    global cnt 

    for i in range(gap,len(num_list)):
        evc = num_list[i]
        j   = i-gap
        while j >= 0 and num_list[j] > evc:
            num_list[j+gap] = num_list[j]
            j = j-gap
            cnt += 1
            num_list[j+gap] = evc

def shell_sort(num_list):
    global cnt
    cnt = 0
    m_list = []
    h = 1
    while h <= len(num_list):
        m_list.append(h)
        h = 3*h+1
    m_list.reverse()
    m = len(m_list)

    print(m)
    print(' '.join([str(i) for i in m_list]))
    for i in range(m):
        insertion_sort(num_list,m_list[i])

n = int(input())
num_list = [int(input()) for _ in range(n)]

shell_sort(num_list)
print(cnt)
for num in num_list:
    print(num) def insertion_sort(num_list,gap):
    global cnt 

    for i in range(gap,len(num_list)):
        evc = num_list[i]
        j   = i-gap
        while j >= 0 and num_list[j] > evc:
            num_list[j+gap] = num_list[j]
            j = j-gap
            cnt += 1
            num_list[j+gap] = evc insertion_sort global cnt for i in range(gap,len(num_list)):
        evc = num_list[i]
        j   = i-gap
        while j >= 0 and num_list[j] > evc:
            num_list[j+gap] = num_list[j]
            j = j-gap
            cnt += 1
            num_list[j+gap] = evc i range(gap,len(num_list)) range gap len(num_list) len num_list evc = num_list[i] evc num_list[i] num_list i j   = i-gap j i-gap i gap while j >= 0 and num_list[j] > evc:
            num_list[j+gap] = num_list[j]
            j = j-gap
            cnt += 1
            num_list[j+gap] = evc j >= 0 and num_list[j] > evc j >= 0 j 0 num_list[j] > evc num_list[j] num_list j evc num_list[j+gap] = num_list[j] num_list[j+gap] num_list j+gap j gap num_list[j] num_list j j = j-gap j j-gap j gap cnt += 1 cnt 1 num_list[j+gap] = evc num_list[j+gap] num_list j+gap j gap evc num_list num_list gap gap def shell_sort(num_list):
    global cnt
    cnt = 0
    m_list = []
    h = 1
    while h <= len(num_list):
        m_list.append(h)
        h = 3*h+1
    m_list.reverse()
    m = len(m_list)

    print(m)
    print(' '.join([str(i) for i in m_list]))
    for i in range(m):
        insertion_sort(num_list,m_list[i]) shell_sort global cnt cnt = 0 cnt 0 m_list = [] m_list [] h = 1 h 1 while h <= len(num_list):
        m_list.append(h)
        h = 3*h+1
     h <= len(num_list) h len(num_list) len num_list m_list.append(h) m_list.append m_list append h h = 3*h+1 h 3*h+1 3*h 3 h 1 m_list.reverse() m_list.reverse m_list reverse m = len(m_list) m len(m_list) len m_list print(m) print m str(i) for i in m_list for i in m_list i m_list for i in m_list str(i) str i print(' '.join([str(i) for i in m_list])) print ' '.join([str(i) for i in m_list]) ' '.join ' ' join [str(i) for i in m_list] for i in range(m):
        insertion_sort(num_list,m_list[i]) i range(m) range m insertion_sort(num_list,m_list[i]) insertion_sort num_list m_list[i] m_list i num_list num_list n = int(input()) n int(input()) int input() input int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input num_list = [int(input()) for _ in range(n)] num_list [int(input()) for _ in range(n)] shell_sort(num_list) shell_sort num_list print(cnt) print cnt for num in num_list:
    print(num) num num_list print(num) print num def insertion_sort(num_list,gap):
    global cnt 

    for i in range(gap,len(num_list)):
        evc = num_list[i]
        j   = i-gap
        while j >= 0 and num_list[j] > evc:
            num_list[j+gap] = num_list[j]
            j = j-gap
            cnt += 1
            num_list[j+gap] = evc def insertion_sort(num_list,gap):
    global cnt 

    for i in range(gap,len(num_list)):
        evc = num_list[i]
        j   = i-gap
        while j >= 0 and num_list[j] > evc:
            num_list[j+gap] = num_list[j]
            j = j-gap
            cnt += 1
            num_list[j+gap] = evc insertion_sort def shell_sort(num_list):
    global cnt
    cnt = 0
    m_list = []
    h = 1
    while h <= len(num_list):
        m_list.append(h)
        h = 3*h+1
    m_list.reverse()
    m = len(m_list)

    print(m)
    print(' '.join([str(i) for i in m_list]))
    for i in range(m):
        insertion_sort(num_list,m_list[i]) def shell_sort(num_list):
    global cnt
    cnt = 0
    m_list = []
    h = 1
    while h <= len(num_list):
        m_list.append(h)
        h = 3*h+1
    m_list.reverse()
    m = len(m_list)

    print(m)
    print(' '.join([str(i) for i in m_list]))
    for i in range(m):
        insertion_sort(num_list,m_list[i]) shell_sort num_list = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] num_list n = int(input()) int(input()) n
def insertion_sort(num_list,gap):
    global cnt 

    for i in range(gap,len(num_list)):
        evc = num_list[i]
        j   = i-gap
        while j >= 0 and num_list[j] > evc:
            num_list[j+gap] = num_list[j]
            j = j-gap
            cnt += 1
            num_list[j+gap] = evc

def shell_sort(num_list):
    global cnt
    cnt = 0
    m_list = []
    h = 1
    while h <= len(num_list):
        m_list.append(h)
        h = 3*h+1
    m_list.reverse()
    m = len(m_list)

    print(m)
    print(' '.join([str(i) for i in m_list]))
    for i in range(m):
        insertion_sort(num_list,m_list[i])

n = int(input())
num_list = [int(input()) for _ in range(n)]

shell_sort(num_list)
print(cnt)
for num in num_list:
    print(num)
