#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Shell Sort
?¬????????????°?????????????????\?????????????????¨?????? n ????????´??°???????????°??? A ??????????????´?????????????????°????????§??????

1  insertionSort(A, n, g)
2      for i = g to n-1
3          v = A[i]
4          j = i - g
5          while j >= 0 && A[j] > v
6              A[j+g] = A[j]
7              j = j - g
8              cnt++
9          A[j+g] = v
10
11 shellSort(A, n)
12     cnt = 0
13     m = ?
14     G[] = {?, ?,..., ?}
15     for i = 0 to m-1
16         insertionSort(A, n, G[i])

shellSort(A, n) ????????????????????? g ????????¢??????????´??????????????±???¨???????????\???????????§??????
 insertionSort(A, n, g) ?????????????????§??????????????? g ????????????????????°??????????????????
 ??????????????§??????????????¨?¨?????????????

???????????????????????? ? ??????????????????????????°???????????????????????????????????????
n ??¨??°??? A ???????????????????????§????????????????????????m??? m ????????´??° Gi(i=0,1,...,m???1)???
??\??? A????????????????????????????????????????????°????????????????????????????????????
???????????????????????\???????????¶????????????????????????????????????

1???m???100
0???Gi???n
cnt ????????? [n^1.5] ????¶??????????????????????
"""
import sys

def insertionSort(A, n, g):
    """ ?????\????????? """
    c = 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
            c += 1
        A[j+g] = v
    return c

def shellSort(A, n):
    cnt = 0
    G = []
    i = 1
    while i <= n:
        G.insert(0,i)
        i = i * 3 + 1
    
    m = len(G)
    for i in range(0, m):
        cnt += insertionSort(A, n, G[i])
    
    # ??????
    print(m)
    print(" ".join(map(str,G)))
    print(cnt)
    for i in A:
        print(i)

# ?????????
n = int(input().strip())
a = []
for i in range(n):
    a.append(int(input().strip()))
shellSort(a,n) """
Shell Sort
?¬????????????°?????????????????\?????????????????¨?????? n ????????´??°???????????°??? A ??????????????´?????????????????°????????§??????

1  insertionSort(A, n, g)
2      for i = g to n-1
3          v = A[i]
4          j = i - g
5          while j >= 0 && A[j] > v
6              A[j+g] = A[j]
7              j = j - g
8              cnt++
9          A[j+g] = v
10
11 shellSort(A, n)
12     cnt = 0
13     m = ?
14     G[] = {?, ?,..., ?}
15     for i = 0 to m-1
16         insertionSort(A, n, G[i])

shellSort(A, n) ????????????????????? g ????????¢??????????´??????????????±???¨???????????\???????????§??????
 insertionSort(A, n, g) ?????????????????§??????????????? g ????????????????????°??????????????????
 ??????????????§??????????????¨?¨?????????????

???????????????????????? ? ??????????????????????????°???????????????????????????????????????
n ??¨??°??? A ???????????????????????§????????????????????????m??? m ????????´??° Gi(i=0,1,...,m???1)???
??\??? A????????????????????????????????????????????°????????????????????????????????????
???????????????????????\???????????¶????????????????????????????????????

1???m???100
0???Gi???n
cnt ????????? [n^1.5] ????¶??????????????????????
""" import sys sys def insertionSort(A, n, g):
    """ ?????\????????? """
    c = 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
            c += 1
        A[j+g] = v
    return c insertionSort """ ?????\????????? """ c = 0 c 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
            c += 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
            c += 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 c += 1 c 1 A[j+g] = v A[j+g] A j+g j g v return c c A A n n g g def shellSort(A, n):
    cnt = 0
    G = []
    i = 1
    while i <= n:
        G.insert(0,i)
        i = i * 3 + 1
    
    m = len(G)
    for i in range(0, m):
        cnt += insertionSort(A, n, G[i])
    
    # ??????
    print(m)
    print(" ".join(map(str,G)))
    print(cnt)
    for i in A:
        print(i)

# ????????? shellSort cnt = 0 cnt 0 G = [] G [] i = 1 i 1 while i <= n:
        G.insert(0,i)
        i = i * 3 + 1
    
     i <= n i n G.insert(0,i) G.insert G insert 0 i i = i * 3 + 1 i i * 3 + 1 i * 3 i 3 1 m = len(G) m len(G) len G for i in range(0, m):
        cnt += insertionSort(A, n, G[i])
    
    # ??????
     i range(0, m) range 0 m cnt += insertionSort(A, n, G[i]) cnt insertionSort(A, n, G[i]) insertionSort A n G[i] G i print(m) print m print(" ".join(map(str,G))) print " ".join(map(str,G)) " ".join " " join map(str,G) map str G print(cnt) print cnt for i in A:
        print(i)

# ????????? i A print(i) print i A A n n n = int(input().strip()) n int(input().strip()) int input().strip() ().strip () input strip a = [] a [] for i in range(n):
    a.append(int(input().strip())) i range(n) range n a.append(int(input().strip())) a.append a append int(input().strip()) int input().strip() ().strip () input strip shellSort(a,n) shellSort a n n = int(input().strip()) int(input().strip()) n def insertionSort(A, n, g):
    """ ?????\????????? """
    c = 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
            c += 1
        A[j+g] = v
    return c def insertionSort(A, n, g):
    """ ?????\????????? """
    c = 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
            c += 1
        A[j+g] = v
    return c insertionSort a = [] [] a def shellSort(A, n):
    cnt = 0
    G = []
    i = 1
    while i <= n:
        G.insert(0,i)
        i = i * 3 + 1
    
    m = len(G)
    for i in range(0, m):
        cnt += insertionSort(A, n, G[i])
    
    # ??????
    print(m)
    print(" ".join(map(str,G)))
    print(cnt)
    for i in A:
        print(i)

# ????????? def shellSort(A, n):
    cnt = 0
    G = []
    i = 1
    while i <= n:
        G.insert(0,i)
        i = i * 3 + 1
    
    m = len(G)
    for i in range(0, m):
        cnt += insertionSort(A, n, G[i])
    
    # ??????
    print(m)
    print(" ".join(map(str,G)))
    print(cnt)
    for i in A:
        print(i)

# ????????? shellSort
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Shell Sort
?¬????????????°?????????????????\?????????????????¨?????? n ????????´??°???????????°??? A ??????????????´?????????????????°????????§??????

1  insertionSort(A, n, g)
2      for i = g to n-1
3          v = A[i]
4          j = i - g
5          while j >= 0 && A[j] > v
6              A[j+g] = A[j]
7              j = j - g
8              cnt++
9          A[j+g] = v
10
11 shellSort(A, n)
12     cnt = 0
13     m = ?
14     G[] = {?, ?,..., ?}
15     for i = 0 to m-1
16         insertionSort(A, n, G[i])

shellSort(A, n) ????????????????????? g ????????¢??????????´??????????????±???¨???????????\???????????§??????
 insertionSort(A, n, g) ?????????????????§??????????????? g ????????????????????°??????????????????
 ??????????????§??????????????¨?¨?????????????

???????????????????????? ? ??????????????????????????°???????????????????????????????????????
n ??¨??°??? A ???????????????????????§????????????????????????m??? m ????????´??° Gi(i=0,1,...,m???1)???
??\??? A????????????????????????????????????????????°????????????????????????????????????
???????????????????????\???????????¶????????????????????????????????????

1???m???100
0???Gi???n
cnt ????????? [n^1.5] ????¶??????????????????????
"""
import sys

def insertionSort(A, n, g):
    """ ?????\????????? """
    c = 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
            c += 1
        A[j+g] = v
    return c

def shellSort(A, n):
    cnt = 0
    G = []
    i = 1
    while i <= n:
        G.insert(0,i)
        i = i * 3 + 1
    
    m = len(G)
    for i in range(0, m):
        cnt += insertionSort(A, n, G[i])
    
    # ??????
    print(m)
    print(" ".join(map(str,G)))
    print(cnt)
    for i in A:
        print(i)

# ?????????
n = int(input().strip())
a = []
for i in range(n):
    a.append(int(input().strip()))
shellSort(a,n)