def insertionSort(a, n, g):
  global cnt
  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

def shellSort(a, n):
  global cnt
  cnt = 0
  g = []
  h = 1
  while h <= len(a):
    g.append(h)
    h = 3 * h + 1
  g.reverse()
  m = len(g)
  for i in range(0, m):
    insertionSort(a, n, g[i])
  print(m)
  print(" ".join(map(str, g)))
  print(cnt)
  for c in a:
    print(c)

n = int(input())
a = [int(input()) for _ in range(n)]
shellSort(a,n) def insertionSort(a, n, g):
  global cnt
  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 insertionSort global cnt 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 a a n n g g def shellSort(a, n):
  global cnt
  cnt = 0
  g = []
  h = 1
  while h <= len(a):
    g.append(h)
    h = 3 * h + 1
  g.reverse()
  m = len(g)
  for i in range(0, m):
    insertionSort(a, n, g[i])
  print(m)
  print(" ".join(map(str, g)))
  print(cnt)
  for c in a:
    print(c) shellSort global cnt cnt = 0 cnt 0 g = [] g [] h = 1 h 1 while h <= len(a):
    g.append(h)
    h = 3 * h + 1
   h <= len(a) h len(a) len a g.append(h) g.append g append h h = 3 * h + 1 h 3 * h + 1 3 * h 3 h 1 g.reverse() g.reverse g reverse m = len(g) m len(g) len g for i in range(0, m):
    insertionSort(a, n, g[i])
   i range(0, m) range 0 m 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 c in a:
    print(c) c a print(c) print c a a n n n = int(input()) n int(input()) int input() input 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)] shellSort(a,n) shellSort a n a = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] a def shellSort(a, n):
  global cnt
  cnt = 0
  g = []
  h = 1
  while h <= len(a):
    g.append(h)
    h = 3 * h + 1
  g.reverse()
  m = len(g)
  for i in range(0, m):
    insertionSort(a, n, g[i])
  print(m)
  print(" ".join(map(str, g)))
  print(cnt)
  for c in a:
    print(c) def shellSort(a, n):
  global cnt
  cnt = 0
  g = []
  h = 1
  while h <= len(a):
    g.append(h)
    h = 3 * h + 1
  g.reverse()
  m = len(g)
  for i in range(0, m):
    insertionSort(a, n, g[i])
  print(m)
  print(" ".join(map(str, g)))
  print(cnt)
  for c in a:
    print(c) shellSort def insertionSort(a, n, g):
  global cnt
  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 def insertionSort(a, n, g):
  global cnt
  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 insertionSort n = int(input()) int(input()) n
def insertionSort(a, n, g):
  global cnt
  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

def shellSort(a, n):
  global cnt
  cnt = 0
  g = []
  h = 1
  while h <= len(a):
    g.append(h)
    h = 3 * h + 1
  g.reverse()
  m = len(g)
  for i in range(0, m):
    insertionSort(a, n, g[i])
  print(m)
  print(" ".join(map(str, g)))
  print(cnt)
  for c in a:
    print(c)

n = int(input())
a = [int(input()) for _ in range(n)]
shellSort(a,n)
