import math


swap_count = 0


def main():
  num = int(input())
  elements = []
  for i in range(0, num):
    elements.append(int(input()))

  # Get intervals
  interval = 1
  intervals = [interval]
  while True:
    interval = int_f(interval)
    if interval > num:
      break
    intervals.insert(0, math.ceil(interval))

  for interval in intervals:
    insertion_sort(elements, num, interval)

  print(len(intervals))
  print(' '.join([str(interval) for interval in intervals]))
  print(swap_count)
  for val in elements:
    print(val)


def int_f(x):
  return 2.25 * x + 1


def insertion_sort(elements, num, interval=1):
  global swap_count

  i = interval
  while i < num:
    j = i
    while interval <= j:
      if elements[j - interval] <= elements[j]:
        break

      elements[j - interval], elements[j] = elements[j], elements[j - interval]
      swap_count += 1
      j -= interval
    i += 1


if __name__ == '__main__':
  main() import math math swap_count = 0 swap_count 0 def main():
  num = int(input())
  elements = []
  for i in range(0, num):
    elements.append(int(input()))

  # Get intervals
  interval = 1
  intervals = [interval]
  while True:
    interval = int_f(interval)
    if interval > num:
      break
    intervals.insert(0, math.ceil(interval))

  for interval in intervals:
    insertion_sort(elements, num, interval)

  print(len(intervals))
  print(' '.join([str(interval) for interval in intervals]))
  print(swap_count)
  for val in elements:
    print(val) main num = int(input()) num int(input()) int input() input elements = [] elements [] for i in range(0, num):
    elements.append(int(input()))

  # Get intervals
   i range(0, num) range 0 num elements.append(int(input())) elements.append elements append int(input()) int input() input interval = 1 interval 1 intervals = [interval] intervals [interval] interval while True:
    interval = int_f(interval)
    if interval > num:
      break
    intervals.insert(0, math.ceil(interval))

   True interval = int_f(interval) interval int_f(interval) int_f interval if interval > num:
      break
     interval > num interval num break intervals.insert(0, math.ceil(interval)) intervals.insert intervals insert 0 math.ceil(interval) math.ceil math ceil interval for interval in intervals:
    insertion_sort(elements, num, interval)

   interval intervals insertion_sort(elements, num, interval) insertion_sort elements num interval print(len(intervals)) print len(intervals) len intervals str(interval) for interval in intervals for interval in intervals interval intervals for interval in intervals str(interval) str interval print(' '.join([str(interval) for interval in intervals])) print ' '.join([str(interval) for interval in intervals]) ' '.join ' ' join [str(interval) for interval in intervals] print(swap_count) print swap_count for val in elements:
    print(val) val elements print(val) print val def int_f(x):
  return 2.25 * x + 1 int_f return 2.25 * x + 1 2.25 * x + 1 2.25 * x 2.25 x 1 x x def insertion_sort(elements, num, interval=1):
  global swap_count

  i = interval
  while i < num:
    j = i
    while interval <= j:
      if elements[j - interval] <= elements[j]:
        break

      elements[j - interval], elements[j] = elements[j], elements[j - interval]
      swap_count += 1
      j -= interval
    i += 1 insertion_sort global swap_count i = interval i interval while i < num:
    j = i
    while interval <= j:
      if elements[j - interval] <= elements[j]:
        break

      elements[j - interval], elements[j] = elements[j], elements[j - interval]
      swap_count += 1
      j -= interval
    i += 1 i < num i num j = i j i while interval <= j:
      if elements[j - interval] <= elements[j]:
        break

      elements[j - interval], elements[j] = elements[j], elements[j - interval]
      swap_count += 1
      j -= interval
     interval <= j interval j if elements[j - interval] <= elements[j]:
        break

       elements[j - interval] <= elements[j] elements[j - interval] elements j - interval j interval elements[j] elements j break elements[j - interval], elements[j] = elements[j], elements[j - interval] elements[j - interval] elements j - interval j interval elements[j] elements j elements[j] elements j elements[j - interval] elements j - interval j interval swap_count += 1 swap_count 1 j -= interval j interval i += 1 i 1 elements elements num num interval=1 interval 1 if __name__ == '__main__':
  main() __name__ == '__main__' __name__ '__main__' main() main def main():
  num = int(input())
  elements = []
  for i in range(0, num):
    elements.append(int(input()))

  # Get intervals
  interval = 1
  intervals = [interval]
  while True:
    interval = int_f(interval)
    if interval > num:
      break
    intervals.insert(0, math.ceil(interval))

  for interval in intervals:
    insertion_sort(elements, num, interval)

  print(len(intervals))
  print(' '.join([str(interval) for interval in intervals]))
  print(swap_count)
  for val in elements:
    print(val) def main():
  num = int(input())
  elements = []
  for i in range(0, num):
    elements.append(int(input()))

  # Get intervals
  interval = 1
  intervals = [interval]
  while True:
    interval = int_f(interval)
    if interval > num:
      break
    intervals.insert(0, math.ceil(interval))

  for interval in intervals:
    insertion_sort(elements, num, interval)

  print(len(intervals))
  print(' '.join([str(interval) for interval in intervals]))
  print(swap_count)
  for val in elements:
    print(val) main def int_f(x):
  return 2.25 * x + 1 def int_f(x):
  return 2.25 * x + 1 int_f def insertion_sort(elements, num, interval=1):
  global swap_count

  i = interval
  while i < num:
    j = i
    while interval <= j:
      if elements[j - interval] <= elements[j]:
        break

      elements[j - interval], elements[j] = elements[j], elements[j - interval]
      swap_count += 1
      j -= interval
    i += 1 def insertion_sort(elements, num, interval=1):
  global swap_count

  i = interval
  while i < num:
    j = i
    while interval <= j:
      if elements[j - interval] <= elements[j]:
        break

      elements[j - interval], elements[j] = elements[j], elements[j - interval]
      swap_count += 1
      j -= interval
    i += 1 insertion_sort swap_count = 0 0 swap_count
import math


swap_count = 0


def main():
  num = int(input())
  elements = []
  for i in range(0, num):
    elements.append(int(input()))

  # Get intervals
  interval = 1
  intervals = [interval]
  while True:
    interval = int_f(interval)
    if interval > num:
      break
    intervals.insert(0, math.ceil(interval))

  for interval in intervals:
    insertion_sort(elements, num, interval)

  print(len(intervals))
  print(' '.join([str(interval) for interval in intervals]))
  print(swap_count)
  for val in elements:
    print(val)


def int_f(x):
  return 2.25 * x + 1


def insertion_sort(elements, num, interval=1):
  global swap_count

  i = interval
  while i < num:
    j = i
    while interval <= j:
      if elements[j - interval] <= elements[j]:
        break

      elements[j - interval], elements[j] = elements[j], elements[j - interval]
      swap_count += 1
      j -= interval
    i += 1


if __name__ == '__main__':
  main()