def insertion_sort(a,n,g):
  global cnt
  for i in range(g,n):
    temp = a[i]
    j = i - g
    while j >= 0 and a[j] > temp:
      a[j + g] = a[j]
      j = j - g
      cnt += 1
    a[j+g] = temp
    
def shell_sort(a,n):
  h = 1
  g = []
  while h <= n:
    g.append(h)
    h = h * 3 + 1
  m = len(g)
  g = g[::-1]
  for i in range(m):
    insertion_sort(a,n,g[i])
  print(m)
  print(' '.join(map(str,g)))
  print(cnt)
  [print(i) for i in a]
    
num = int(input())
a = []
cnt = 0
for i in range(num):
  a.append(int(input()))
shell_sort(a,num)
print(cnt) def insertion_sort(a,n,g):
  global cnt
  for i in range(g,n):
    temp = a[i]
    j = i - g
    while j >= 0 and a[j] > temp:
      a[j + g] = a[j]
      j = j - g
      cnt += 1
    a[j+g] = temp
     insertion_sort global cnt for i in range(g,n):
    temp = a[i]
    j = i - g
    while j >= 0 and a[j] > temp:
      a[j + g] = a[j]
      j = j - g
      cnt += 1
    a[j+g] = temp
     i range(g,n) range g n temp = a[i] temp a[i] a i j = i - g j i - g i g while j >= 0 and a[j] > temp:
      a[j + g] = a[j]
      j = j - g
      cnt += 1
     j >= 0 and a[j] > temp j >= 0 j 0 a[j] > temp a[j] a j temp 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] = temp a[j+g] a j+g j g temp a a n n g g def shell_sort(a,n):
  h = 1
  g = []
  while h <= n:
    g.append(h)
    h = h * 3 + 1
  m = len(g)
  g = g[::-1]
  for i in range(m):
    insertion_sort(a,n,g[i])
  print(m)
  print(' '.join(map(str,g)))
  print(cnt)
  [print(i) for i in a]
     shell_sort h = 1 h 1 g = [] g [] while h <= n:
    g.append(h)
    h = h * 3 + 1
   h <= n h n g.append(h) g.append g append h h = h * 3 + 1 h h * 3 + 1 h * 3 h 3 1 m = len(g) m len(g) len g g = g[::-1] g g[::-1] g ::-1 -1 for i in range(m):
    insertion_sort(a,n,g[i])
   i range(m) range m insertion_sort(a,n,g[i]) insertion_sort 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 print(i) for i in a for i in a i a for i in a print(i) print i [print(i) for i in a] a a n n num = int(input()) num int(input()) int input() input a = [] a [] cnt = 0 cnt 0 for i in range(num):
  a.append(int(input())) i range(num) range num a.append(int(input())) a.append a append int(input()) int input() input shell_sort(a,num) shell_sort a num print(cnt) print cnt def insertion_sort(a,n,g):
  global cnt
  for i in range(g,n):
    temp = a[i]
    j = i - g
    while j >= 0 and a[j] > temp:
      a[j + g] = a[j]
      j = j - g
      cnt += 1
    a[j+g] = temp
     def insertion_sort(a,n,g):
  global cnt
  for i in range(g,n):
    temp = a[i]
    j = i - g
    while j >= 0 and a[j] > temp:
      a[j + g] = a[j]
      j = j - g
      cnt += 1
    a[j+g] = temp
     insertion_sort def shell_sort(a,n):
  h = 1
  g = []
  while h <= n:
    g.append(h)
    h = h * 3 + 1
  m = len(g)
  g = g[::-1]
  for i in range(m):
    insertion_sort(a,n,g[i])
  print(m)
  print(' '.join(map(str,g)))
  print(cnt)
  [print(i) for i in a]
     def shell_sort(a,n):
  h = 1
  g = []
  while h <= n:
    g.append(h)
    h = h * 3 + 1
  m = len(g)
  g = g[::-1]
  for i in range(m):
    insertion_sort(a,n,g[i])
  print(m)
  print(' '.join(map(str,g)))
  print(cnt)
  [print(i) for i in a]
     shell_sort a = [] [] a num = int(input()) int(input()) num cnt = 0 0 cnt
def insertion_sort(a,n,g):
  global cnt
  for i in range(g,n):
    temp = a[i]
    j = i - g
    while j >= 0 and a[j] > temp:
      a[j + g] = a[j]
      j = j - g
      cnt += 1
    a[j+g] = temp
    
def shell_sort(a,n):
  h = 1
  g = []
  while h <= n:
    g.append(h)
    h = h * 3 + 1
  m = len(g)
  g = g[::-1]
  for i in range(m):
    insertion_sort(a,n,g[i])
  print(m)
  print(' '.join(map(str,g)))
  print(cnt)
  [print(i) for i in a]
    
num = int(input())
a = []
cnt = 0
for i in range(num):
  a.append(int(input()))
shell_sort(a,num)
print(cnt)
