n = int(input())
A = [None] * n
for i in range(n):
  A[i] = int(input())

def insertionSort(A, n, g):
  cnt = 0
  for i in range(g, n, 1):
    # Insertion Sort
    # e.g. if g == 4 and i == 8:  [4] 6  2  1 [10] 8  9  5 [3] 7
    j = i - g  # e.g. j = 4
    k = i      # e.g. k = 8
    while j >= 0 and A[j] > A[k]:
      #print("i:{} j:{} k:{} A:{}".format(i, j, k, A))
      A[j], A[k] = A[k], A[j]
      k = j       # e.g. k = 4
      j = k - g   # e.g. j = 4 - 0 = 0
      cnt += 1
      #print("j reduced to {}, k reduced to {}".format(j, k))

  return(cnt)

def shellSort(A, n):
  g = [0]
  m = 0
  sum = 0
  while True:
    if (3*m + 1 <= n):
      g.insert(0, 3*m + 1)
      m = 3*m + 1
    else:
      break
  
  for i in range(len(g)):
    cnt = insertionSort(A, n, g[i])
    sum += cnt

  print(len(g))
  print(str(g).replace('[', '').replace(']', '').replace(',', ''))
  print(sum)
  for i in range(n):
    print(A[i])

def main():
  shellSort(A, n)

main()
 n = int(input()) n int(input()) int input() input A = [None] * n A [None] * n [None] None n for i in range(n):
  A[i] = int(input()) i range(n) range n A[i] = int(input()) A[i] A i int(input()) int input() input def insertionSort(A, n, g):
  cnt = 0
  for i in range(g, n, 1):
    # Insertion Sort
    # e.g. if g == 4 and i == 8:  [4] 6  2  1 [10] 8  9  5 [3] 7
    j = i - g  # e.g. j = 4
    k = i      # e.g. k = 8
    while j >= 0 and A[j] > A[k]:
      #print("i:{} j:{} k:{} A:{}".format(i, j, k, A))
      A[j], A[k] = A[k], A[j]
      k = j       # e.g. k = 4
      j = k - g   # e.g. j = 4 - 0 = 0
      cnt += 1
      #print("j reduced to {}, k reduced to {}".format(j, k))

  return(cnt) insertionSort cnt = 0 cnt 0 for i in range(g, n, 1):
    # Insertion Sort
    # e.g. if g == 4 and i == 8:  [4] 6  2  1 [10] 8  9  5 [3] 7
    j = i - g  # e.g. j = 4
    k = i      # e.g. k = 8
    while j >= 0 and A[j] > A[k]:
      #print("i:{} j:{} k:{} A:{}".format(i, j, k, A))
      A[j], A[k] = A[k], A[j]
      k = j       # e.g. k = 4
      j = k - g   # e.g. j = 4 - 0 = 0
      cnt += 1
      #print("j reduced to {}, k reduced to {}".format(j, k))

   i range(g, n, 1) range g n 1 j = i - g j i - g i g k = i k i while j >= 0 and A[j] > A[k]:
      #print("i:{} j:{} k:{} A:{}".format(i, j, k, A))
      A[j], A[k] = A[k], A[j]
      k = j       # e.g. k = 4
      j = k - g   # e.g. j = 4 - 0 = 0
      cnt += 1
      #print("j reduced to {}, k reduced to {}".format(j, k))

   j >= 0 and A[j] > A[k] j >= 0 j 0 A[j] > A[k] A[j] A j A[k] A k A[j], A[k] = A[k], A[j] A[j] A j A[k] A k A[k] A k A[j] A j k = j k j j = k - g j k - g k g cnt += 1 cnt 1 return(cnt) cnt A A n n g g def shellSort(A, n):
  g = [0]
  m = 0
  sum = 0
  while True:
    if (3*m + 1 <= n):
      g.insert(0, 3*m + 1)
      m = 3*m + 1
    else:
      break
  
  for i in range(len(g)):
    cnt = insertionSort(A, n, g[i])
    sum += cnt

  print(len(g))
  print(str(g).replace('[', '').replace(']', '').replace(',', ''))
  print(sum)
  for i in range(n):
    print(A[i]) shellSort g = [0] g [0] 0 m = 0 m 0 sum = 0 sum 0 while True:
    if (3*m + 1 <= n):
      g.insert(0, 3*m + 1)
      m = 3*m + 1
    else:
      break
  
   True if (3*m + 1 <= n):
      g.insert(0, 3*m + 1)
      m = 3*m + 1
    else:
      break
  
   3*m + 1 <= n 3*m + 1 3*m 3 m 1 n g.insert(0, 3*m + 1) g.insert g insert 0 3*m + 1 3*m 3 m 1 m = 3*m + 1 m 3*m + 1 3*m 3 m 1 break for i in range(len(g)):
    cnt = insertionSort(A, n, g[i])
    sum += cnt

   i range(len(g)) range len(g) len g cnt = insertionSort(A, n, g[i]) cnt insertionSort(A, n, g[i]) insertionSort A n g[i] g i sum += cnt sum cnt print(len(g)) print len(g) len g print(str(g).replace('[', '').replace(']', '').replace(',', '')) print str(g).replace('[', '').replace(']', '').replace(',', '') (g).replace('[', '').replace(']', '').replace (g).replace('[', '').replace(']', '') (g).replace('[', '').replace (g).replace('[', '') (g).replace (g) str g replace '[' '' replace ']' '' replace ',' '' print(sum) print sum for i in range(n):
    print(A[i]) i range(n) range n print(A[i]) print A[i] A i A A n n def main():
  shellSort(A, n) main shellSort(A, n) shellSort A n main() main def insertionSort(A, n, g):
  cnt = 0
  for i in range(g, n, 1):
    # Insertion Sort
    # e.g. if g == 4 and i == 8:  [4] 6  2  1 [10] 8  9  5 [3] 7
    j = i - g  # e.g. j = 4
    k = i      # e.g. k = 8
    while j >= 0 and A[j] > A[k]:
      #print("i:{} j:{} k:{} A:{}".format(i, j, k, A))
      A[j], A[k] = A[k], A[j]
      k = j       # e.g. k = 4
      j = k - g   # e.g. j = 4 - 0 = 0
      cnt += 1
      #print("j reduced to {}, k reduced to {}".format(j, k))

  return(cnt) def insertionSort(A, n, g):
  cnt = 0
  for i in range(g, n, 1):
    # Insertion Sort
    # e.g. if g == 4 and i == 8:  [4] 6  2  1 [10] 8  9  5 [3] 7
    j = i - g  # e.g. j = 4
    k = i      # e.g. k = 8
    while j >= 0 and A[j] > A[k]:
      #print("i:{} j:{} k:{} A:{}".format(i, j, k, A))
      A[j], A[k] = A[k], A[j]
      k = j       # e.g. k = 4
      j = k - g   # e.g. j = 4 - 0 = 0
      cnt += 1
      #print("j reduced to {}, k reduced to {}".format(j, k))

  return(cnt) insertionSort def shellSort(A, n):
  g = [0]
  m = 0
  sum = 0
  while True:
    if (3*m + 1 <= n):
      g.insert(0, 3*m + 1)
      m = 3*m + 1
    else:
      break
  
  for i in range(len(g)):
    cnt = insertionSort(A, n, g[i])
    sum += cnt

  print(len(g))
  print(str(g).replace('[', '').replace(']', '').replace(',', ''))
  print(sum)
  for i in range(n):
    print(A[i]) def shellSort(A, n):
  g = [0]
  m = 0
  sum = 0
  while True:
    if (3*m + 1 <= n):
      g.insert(0, 3*m + 1)
      m = 3*m + 1
    else:
      break
  
  for i in range(len(g)):
    cnt = insertionSort(A, n, g[i])
    sum += cnt

  print(len(g))
  print(str(g).replace('[', '').replace(']', '').replace(',', ''))
  print(sum)
  for i in range(n):
    print(A[i]) shellSort A = [None] * n [None] * n A n = int(input()) int(input()) n def main():
  shellSort(A, n) def main():
  shellSort(A, n) main
n = int(input())
A = [None] * n
for i in range(n):
  A[i] = int(input())

def insertionSort(A, n, g):
  cnt = 0
  for i in range(g, n, 1):
    # Insertion Sort
    # e.g. if g == 4 and i == 8:  [4] 6  2  1 [10] 8  9  5 [3] 7
    j = i - g  # e.g. j = 4
    k = i      # e.g. k = 8
    while j >= 0 and A[j] > A[k]:
      #print("i:{} j:{} k:{} A:{}".format(i, j, k, A))
      A[j], A[k] = A[k], A[j]
      k = j       # e.g. k = 4
      j = k - g   # e.g. j = 4 - 0 = 0
      cnt += 1
      #print("j reduced to {}, k reduced to {}".format(j, k))

  return(cnt)

def shellSort(A, n):
  g = [0]
  m = 0
  sum = 0
  while True:
    if (3*m + 1 <= n):
      g.insert(0, 3*m + 1)
      m = 3*m + 1
    else:
      break
  
  for i in range(len(g)):
    cnt = insertionSort(A, n, g[i])
    sum += cnt

  print(len(g))
  print(str(g).replace('[', '').replace(']', '').replace(',', ''))
  print(sum)
  for i in range(n):
    print(A[i])

def main():
  shellSort(A, n)

main()

