# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_D
sample_input = list(range(3))
sample_input[0] = '''5
5
1
4
3
2'''
sample_input[1] = '''3
3
2
1'''
sample_input[2] = '''5
5
1
4
3
2'''
give_sample_input = None
if give_sample_input is not None:
    sample_input_list = sample_input[give_sample_input].split('\n')
    def input():
        return sample_input_list.pop(0)
        
# main
def print_list(l):
    output = ''
    for elem in l:
        output += str(elem) + ' '
    output = output.rstrip()
    print(output)

def determine_G(n):
    G = []
    pot = 1
    while True:
        pot *= 2
        if pot-1 > n:
            break
        G.append(pot-1)
    G.reverse()
    return G

def log_m_floor(n):
    m = 2
    pot = 1
    power = 0
    while (pot < n):
        pot *= 2
        power += 1
    return power

def insertion_sort(A, n, g):
    cnt = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while (j >= 0 and A[j] > v):
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return cnt

def shell_sort(A, n):
    cnt = 0
    G = determine_G(n)
    m = len(G)
    if m == 0:
        print(1)
        print(1)
        print(0)
        return
    print(m)
    print_list(G)
    for i in range(m):
        cnt += insertion_sort(A, n, G[i])
    print(cnt)
        
num_of_data = int(input())
data = []
for i in range(num_of_data):
    data.append(int(input()))
shell_sort(data, num_of_data)
for d in data:
    print(d) sample_input = list(range(3)) sample_input list(range(3)) list range(3) range 3 sample_input[0] = '''5
5
1
4
3
2''' sample_input[0] sample_input 0 '''5
5
1
4
3
2''' sample_input[1] = '''3
3
2
1''' sample_input[1] sample_input 1 '''3
3
2
1''' sample_input[2] = '''5
5
1
4
3
2''' sample_input[2] sample_input 2 '''5
5
1
4
3
2''' give_sample_input = None give_sample_input None if give_sample_input is not None:
    sample_input_list = sample_input[give_sample_input].split('\n')
    def input():
        return sample_input_list.pop(0)
        
# main give_sample_input is not None give_sample_input None sample_input_list = sample_input[give_sample_input].split('\n') sample_input_list sample_input[give_sample_input].split('\n') [give_sample_input].split [give_sample_input] sample_input give_sample_input split '\n' def input():
        return sample_input_list.pop(0)
        
# main input return sample_input_list.pop(0) sample_input_list.pop(0) sample_input_list.pop sample_input_list pop 0 def print_list(l):
    output = ''
    for elem in l:
        output += str(elem) + ' '
    output = output.rstrip()
    print(output) print_list output = '' output '' for elem in l:
        output += str(elem) + ' '
     elem l output += str(elem) + ' ' output str(elem) + ' ' str(elem) str elem ' ' output = output.rstrip() output output.rstrip() output.rstrip output rstrip print(output) print output l l def determine_G(n):
    G = []
    pot = 1
    while True:
        pot *= 2
        if pot-1 > n:
            break
        G.append(pot-1)
    G.reverse()
    return G determine_G G = [] G [] pot = 1 pot 1 while True:
        pot *= 2
        if pot-1 > n:
            break
        G.append(pot-1)
     True pot *= 2 pot 2 if pot-1 > n:
            break
         pot-1 > n pot-1 pot 1 n break G.append(pot-1) G.append G append pot-1 pot 1 G.reverse() G.reverse G reverse return G G n n def log_m_floor(n):
    m = 2
    pot = 1
    power = 0
    while (pot < n):
        pot *= 2
        power += 1
    return power log_m_floor m = 2 m 2 pot = 1 pot 1 power = 0 power 0 while (pot < n):
        pot *= 2
        power += 1
     pot < n pot n pot *= 2 pot 2 power += 1 power 1 return power power n n def insertion_sort(A, n, g):
    cnt = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while (j >= 0 and A[j] > v):
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return cnt insertion_sort cnt = 0 cnt 0 for i in range(g, n):
        v = A[i]
        j = i - g
        while (j >= 0 and A[j] > v):
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
     i range(g, n) range g n 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 = 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 = j - g j j - g j g cnt += 1 cnt 1 A[j+g] = v A[j+g] A j+g j g v return cnt cnt A A n n g g def shell_sort(A, n):
    cnt = 0
    G = determine_G(n)
    m = len(G)
    if m == 0:
        print(1)
        print(1)
        print(0)
        return
    print(m)
    print_list(G)
    for i in range(m):
        cnt += insertion_sort(A, n, G[i])
    print(cnt)
         shell_sort cnt = 0 cnt 0 G = determine_G(n) G determine_G(n) determine_G n m = len(G) m len(G) len G if m == 0:
        print(1)
        print(1)
        print(0)
        return
     m == 0 m 0 print(1) print 1 print(1) print 1 print(0) print 0 return print(m) print m print_list(G) print_list G for i in range(m):
        cnt += insertion_sort(A, n, G[i])
     i range(m) range m cnt += insertion_sort(A, n, G[i]) cnt insertion_sort(A, n, G[i]) insertion_sort A n G[i] G i print(cnt) print cnt A A n n num_of_data = int(input()) num_of_data int(input()) int input() input data = [] data [] for i in range(num_of_data):
    data.append(int(input())) i range(num_of_data) range num_of_data data.append(int(input())) data.append data append int(input()) int input() input shell_sort(data, num_of_data) shell_sort data num_of_data for d in data:
    print(d) d data print(d) print d sample_input = list(range(3)) list(range(3)) sample_input num_of_data = int(input()) int(input()) num_of_data sample_input_list = sample_input[give_sample_input].split('\n') sample_input[give_sample_input].split('\n') sample_input_list def determine_G(n):
    G = []
    pot = 1
    while True:
        pot *= 2
        if pot-1 > n:
            break
        G.append(pot-1)
    G.reverse()
    return G def determine_G(n):
    G = []
    pot = 1
    while True:
        pot *= 2
        if pot-1 > n:
            break
        G.append(pot-1)
    G.reverse()
    return G determine_G def log_m_floor(n):
    m = 2
    pot = 1
    power = 0
    while (pot < n):
        pot *= 2
        power += 1
    return power def log_m_floor(n):
    m = 2
    pot = 1
    power = 0
    while (pot < n):
        pot *= 2
        power += 1
    return power log_m_floor def shell_sort(A, n):
    cnt = 0
    G = determine_G(n)
    m = len(G)
    if m == 0:
        print(1)
        print(1)
        print(0)
        return
    print(m)
    print_list(G)
    for i in range(m):
        cnt += insertion_sort(A, n, G[i])
    print(cnt)
         def shell_sort(A, n):
    cnt = 0
    G = determine_G(n)
    m = len(G)
    if m == 0:
        print(1)
        print(1)
        print(0)
        return
    print(m)
    print_list(G)
    for i in range(m):
        cnt += insertion_sort(A, n, G[i])
    print(cnt)
         shell_sort def input():
        return sample_input_list.pop(0)
        
# main def input():
        return sample_input_list.pop(0)
        
# main input def print_list(l):
    output = ''
    for elem in l:
        output += str(elem) + ' '
    output = output.rstrip()
    print(output) def print_list(l):
    output = ''
    for elem in l:
        output += str(elem) + ' '
    output = output.rstrip()
    print(output) print_list def insertion_sort(A, n, g):
    cnt = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while (j >= 0 and A[j] > v):
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return cnt def insertion_sort(A, n, g):
    cnt = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while (j >= 0 and A[j] > v):
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return cnt insertion_sort data = [] [] data give_sample_input = None None give_sample_input
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_D
sample_input = list(range(3))
sample_input[0] = '''5
5
1
4
3
2'''
sample_input[1] = '''3
3
2
1'''
sample_input[2] = '''5
5
1
4
3
2'''
give_sample_input = None
if give_sample_input is not None:
    sample_input_list = sample_input[give_sample_input].split('\n')
    def input():
        return sample_input_list.pop(0)
        
# main
def print_list(l):
    output = ''
    for elem in l:
        output += str(elem) + ' '
    output = output.rstrip()
    print(output)

def determine_G(n):
    G = []
    pot = 1
    while True:
        pot *= 2
        if pot-1 > n:
            break
        G.append(pot-1)
    G.reverse()
    return G

def log_m_floor(n):
    m = 2
    pot = 1
    power = 0
    while (pot < n):
        pot *= 2
        power += 1
    return power

def insertion_sort(A, n, g):
    cnt = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while (j >= 0 and A[j] > v):
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return cnt

def shell_sort(A, n):
    cnt = 0
    G = determine_G(n)
    m = len(G)
    if m == 0:
        print(1)
        print(1)
        print(0)
        return
    print(m)
    print_list(G)
    for i in range(m):
        cnt += insertion_sort(A, n, G[i])
    print(cnt)
        
num_of_data = int(input())
data = []
for i in range(num_of_data):
    data.append(int(input()))
shell_sort(data, num_of_data)
for d in data:
    print(d)