def insertion_sort(a, n, g):
    global count
    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
            count += 1
        a[j+g] = v

def shell_sort(a, n):

    g = []
    i = 1
    while i <= len(a):
      g.append(i)
      i = i*3 +1
    g.reverse()
    print(len(g))
    print(" ".join(map(str, g)))
    
    for i in g:
        insertion_sort(a=a, n=n, g=i)

        
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))

count = 0
shell_sort(a=a, n=n)
print(count)
for i in range(n):
  print(a[i])




    
         def insertion_sort(a, n, g):
    global count
    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
            count += 1
        a[j+g] = v insertion_sort global count 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
            count += 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
            count += 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 count += 1 count 1 a[j+g] = v a[j+g] a j+g j g v a a n n g g def shell_sort(a, n):

    g = []
    i = 1
    while i <= len(a):
      g.append(i)
      i = i*3 +1
    g.reverse()
    print(len(g))
    print(" ".join(map(str, g)))
    
    for i in g:
        insertion_sort(a=a, n=n, g=i)

         shell_sort g = [] g [] i = 1 i 1 while i <= len(a):
      g.append(i)
      i = i*3 +1
     i <= len(a) i len(a) len a g.append(i) g.append g append i i = i*3 +1 i i*3 +1 i*3 i 3 1 g.reverse() g.reverse g reverse print(len(g)) print len(g) len g print(" ".join(map(str, g))) print " ".join(map(str, g)) " ".join " " join map(str, g) map str g for i in g:
        insertion_sort(a=a, n=n, g=i)

         i g insertion_sort(a=a, n=n, g=i) insertion_sort a=a a a n=n n n g=i g i a a n n n = int(input()) n int(input()) int input() input a = [] a [] for i in range(n):
  a.append(int(input())) i range(n) range n a.append(int(input())) a.append a append int(input()) int input() input count = 0 count 0 shell_sort(a=a, n=n) shell_sort a=a a a n=n n n print(count) print count for i in range(n):
  print(a[i])




    
         i range(n) range n print(a[i]) print a[i] a i def insertion_sort(a, n, g):
    global count
    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
            count += 1
        a[j+g] = v def insertion_sort(a, n, g):
    global count
    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
            count += 1
        a[j+g] = v insertion_sort n = int(input()) int(input()) n a = [] [] a def shell_sort(a, n):

    g = []
    i = 1
    while i <= len(a):
      g.append(i)
      i = i*3 +1
    g.reverse()
    print(len(g))
    print(" ".join(map(str, g)))
    
    for i in g:
        insertion_sort(a=a, n=n, g=i)

         def shell_sort(a, n):

    g = []
    i = 1
    while i <= len(a):
      g.append(i)
      i = i*3 +1
    g.reverse()
    print(len(g))
    print(" ".join(map(str, g)))
    
    for i in g:
        insertion_sort(a=a, n=n, g=i)

         shell_sort count = 0 0 count
def insertion_sort(a, n, g):
    global count
    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
            count += 1
        a[j+g] = v

def shell_sort(a, n):

    g = []
    i = 1
    while i <= len(a):
      g.append(i)
      i = i*3 +1
    g.reverse()
    print(len(g))
    print(" ".join(map(str, g)))
    
    for i in g:
        insertion_sort(a=a, n=n, g=i)

        
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))

count = 0
shell_sort(a=a, n=n)
print(count)
for i in range(n):
  print(a[i])




    
        
