def insertion_sort(a, g, 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 = j - g
      cnt += 1
    a[j+g] = v
  return cnt

n = int(input())
g = [1]
t = 1
cnt = 0
while 1:
  t = 3 * t + 1
  if t < n and len(g) < 100:
    g += [t]
  else:
    g = g[::-1]
    break
a = [int(input()) for _ in range(n)]
for i in range(0, len(g)):
  cnt = insertion_sort(a, g[i], cnt)
print(len(g))
print(*g)
print(cnt)
for i in a: print(i) def insertion_sort(a, g, 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 = j - g
      cnt += 1
    a[j+g] = v
  return cnt insertion_sort 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 = 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 = 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 g g cnt cnt n = int(input()) n int(input()) int input() input g = [1] g [1] 1 t = 1 t 1 cnt = 0 cnt 0 while 1:
  t = 3 * t + 1
  if t < n and len(g) < 100:
    g += [t]
  else:
    g = g[::-1]
    break 1 t = 3 * t + 1 t 3 * t + 1 3 * t 3 t 1 if t < n and len(g) < 100:
    g += [t]
  else:
    g = g[::-1]
    break t < n and len(g) < 100 t < n t n len(g) < 100 len(g) len g 100 g += [t] g [t] t g = g[::-1] g g[::-1] g ::-1 -1 break int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input a = [int(input()) for _ in range(n)] a [int(input()) for _ in range(n)] for i in range(0, len(g)):
  cnt = insertion_sort(a, g[i], cnt) i range(0, len(g)) range 0 len(g) len g cnt = insertion_sort(a, g[i], cnt) cnt insertion_sort(a, g[i], cnt) insertion_sort a g[i] g i cnt print(len(g)) print len(g) len g print(*g) print *g g print(cnt) print cnt for i in a: print(i) i a cnt = 0 0 cnt t = 1 1 t n = int(input()) int(input()) n g = g[::-1] g[::-1] g g = [1] [1] g a = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] a cnt = insertion_sort(a, g[i], cnt) insertion_sort(a, g[i], cnt) cnt def insertion_sort(a, g, 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 = j - g
      cnt += 1
    a[j+g] = v
  return cnt def insertion_sort(a, g, 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 = j - g
      cnt += 1
    a[j+g] = v
  return cnt insertion_sort g += [t] [t] g t = 3 * t + 1 3 * t + 1 t
def insertion_sort(a, g, 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 = j - g
      cnt += 1
    a[j+g] = v
  return cnt

n = int(input())
g = [1]
t = 1
cnt = 0
while 1:
  t = 3 * t + 1
  if t < n and len(g) < 100:
    g += [t]
  else:
    g = g[::-1]
    break
a = [int(input()) for _ in range(n)]
for i in range(0, len(g)):
  cnt = insertion_sort(a, g[i], cnt)
print(len(g))
print(*g)
print(cnt)
for i in a: print(i)
