# -*- coding:utf-8 -*-

cnt = 0
def insection_sort(a, g):
    global cnt
    for i in range(g, len(a)):
        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 shell_sort(a):
    g = [1]
    temp = 4
    while temp < len(a):
        g.append(temp)
        temp = 3 * temp + 1

    print(len(g))
    for youso in reversed(g):
        if youso != 1:
            print(youso, end=' ')
        else:
            print(youso)
        insection_sort(a, youso)

inp_num = int(input())
a = list()
for i in range(inp_num):
    a.append(int(input()))
shell_sort(a)
print(cnt)
for i in a:
    print(i) cnt = 0 cnt 0 def insection_sort(a, g):
    global cnt
    for i in range(g, len(a)):
        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 insection_sort global cnt for i in range(g, len(a)):
        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, len(a)) range g len(a) len a 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 g g def shell_sort(a):
    g = [1]
    temp = 4
    while temp < len(a):
        g.append(temp)
        temp = 3 * temp + 1

    print(len(g))
    for youso in reversed(g):
        if youso != 1:
            print(youso, end=' ')
        else:
            print(youso)
        insection_sort(a, youso) shell_sort g = [1] g [1] 1 temp = 4 temp 4 while temp < len(a):
        g.append(temp)
        temp = 3 * temp + 1

     temp < len(a) temp len(a) len a g.append(temp) g.append g append temp temp = 3 * temp + 1 temp 3 * temp + 1 3 * temp 3 temp 1 print(len(g)) print len(g) len g for youso in reversed(g):
        if youso != 1:
            print(youso, end=' ')
        else:
            print(youso)
        insection_sort(a, youso) youso reversed(g) reversed g if youso != 1:
            print(youso, end=' ')
        else:
            print(youso)
         youso != 1 youso 1 print(youso, end=' ') print youso end=' ' end ' ' print(youso) print youso insection_sort(a, youso) insection_sort a youso a a inp_num = int(input()) inp_num int(input()) int input() input a = list() a list() list for i in range(inp_num):
    a.append(int(input())) i range(inp_num) range inp_num a.append(int(input())) a.append a append int(input()) int input() input shell_sort(a) shell_sort a print(cnt) print cnt for i in a:
    print(i) i a print(i) print i cnt = 0 0 cnt inp_num = int(input()) int(input()) inp_num def insection_sort(a, g):
    global cnt
    for i in range(g, len(a)):
        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 insection_sort(a, g):
    global cnt
    for i in range(g, len(a)):
        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 insection_sort def shell_sort(a):
    g = [1]
    temp = 4
    while temp < len(a):
        g.append(temp)
        temp = 3 * temp + 1

    print(len(g))
    for youso in reversed(g):
        if youso != 1:
            print(youso, end=' ')
        else:
            print(youso)
        insection_sort(a, youso) def shell_sort(a):
    g = [1]
    temp = 4
    while temp < len(a):
        g.append(temp)
        temp = 3 * temp + 1

    print(len(g))
    for youso in reversed(g):
        if youso != 1:
            print(youso, end=' ')
        else:
            print(youso)
        insection_sort(a, youso) shell_sort a = list() list() a
# -*- coding:utf-8 -*-

cnt = 0
def insection_sort(a, g):
    global cnt
    for i in range(g, len(a)):
        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 shell_sort(a):
    g = [1]
    temp = 4
    while temp < len(a):
        g.append(temp)
        temp = 3 * temp + 1

    print(len(g))
    for youso in reversed(g):
        if youso != 1:
            print(youso, end=' ')
        else:
            print(youso)
        insection_sort(a, youso)

inp_num = int(input())
a = list()
for i in range(inp_num):
    a.append(int(input()))
shell_sort(a)
print(cnt)
for i in a:
    print(i)