# import math
# import itertools
# import numpy as np

def insertionSort(A, n, g, 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

  return [A, cnt]

def shellSort(A, n):
  cnt = 0

  # if n > 4:
  #   G = [4,1]
  # else:
  #   G = [1]

  G = [1]
  i = 1

  while G[0] + 3 ** i < n:
    G.insert(0, G[0] + 3 ** i)
    i += 1

  m = len(G)

  for i in range(m):
    A, cnt = insertionSort(A, n, G[i], cnt)

  return [m, G, A, cnt]

def main():
  n = int(input())
  A = [int(input()) for _ in range(n)]

  m, G, A, cnt = shellSort(A, n)

  print(m)
  print(*G)
  print(cnt)
  for num in A:
    print(num)

if __name__ == '__main__':
  main() def insertionSort(A, n, g, 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

  return [A, cnt] insertionSort 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 return [A, cnt] [A, cnt] A cnt A A n n g g cnt cnt def shellSort(A, n):
  cnt = 0

  # if n > 4:
  #   G = [4,1]
  # else:
  #   G = [1]

  G = [1]
  i = 1

  while G[0] + 3 ** i < n:
    G.insert(0, G[0] + 3 ** i)
    i += 1

  m = len(G)

  for i in range(m):
    A, cnt = insertionSort(A, n, G[i], cnt)

  return [m, G, A, cnt] shellSort cnt = 0 cnt 0 G = [1] G [1] 1 i = 1 i 1 while G[0] + 3 ** i < n:
    G.insert(0, G[0] + 3 ** i)
    i += 1

   G[0] + 3 ** i < n G[0] + 3 ** i G[0] G 0 3 ** i 3 i n G.insert(0, G[0] + 3 ** i) G.insert G insert 0 G[0] + 3 ** i G[0] G 0 3 ** i 3 i i += 1 i 1 m = len(G) m len(G) len G for i in range(m):
    A, cnt = insertionSort(A, n, G[i], cnt)

   i range(m) range m A, cnt = insertionSort(A, n, G[i], cnt) A insertionSort(A, n, G[i], cnt) insertionSort A n G[i] G i cnt cnt return [m, G, A, cnt] [m, G, A, cnt] m G A cnt A A n n def main():
  n = int(input())
  A = [int(input()) for _ in range(n)]

  m, G, A, cnt = shellSort(A, n)

  print(m)
  print(*G)
  print(cnt)
  for num in A:
    print(num) main 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)] m, G, A, cnt = shellSort(A, n) m shellSort(A, n) shellSort A n G A cnt print(m) print m print(*G) print *G G print(cnt) print cnt for num in A:
    print(num) num A print(num) print num if __name__ == '__main__':
  main() __name__ == '__main__' __name__ '__main__' main() main def insertionSort(A, n, g, 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

  return [A, cnt] def insertionSort(A, n, g, 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

  return [A, cnt] insertionSort def shellSort(A, n):
  cnt = 0

  # if n > 4:
  #   G = [4,1]
  # else:
  #   G = [1]

  G = [1]
  i = 1

  while G[0] + 3 ** i < n:
    G.insert(0, G[0] + 3 ** i)
    i += 1

  m = len(G)

  for i in range(m):
    A, cnt = insertionSort(A, n, G[i], cnt)

  return [m, G, A, cnt] def shellSort(A, n):
  cnt = 0

  # if n > 4:
  #   G = [4,1]
  # else:
  #   G = [1]

  G = [1]
  i = 1

  while G[0] + 3 ** i < n:
    G.insert(0, G[0] + 3 ** i)
    i += 1

  m = len(G)

  for i in range(m):
    A, cnt = insertionSort(A, n, G[i], cnt)

  return [m, G, A, cnt] shellSort def main():
  n = int(input())
  A = [int(input()) for _ in range(n)]

  m, G, A, cnt = shellSort(A, n)

  print(m)
  print(*G)
  print(cnt)
  for num in A:
    print(num) def main():
  n = int(input())
  A = [int(input()) for _ in range(n)]

  m, G, A, cnt = shellSort(A, n)

  print(m)
  print(*G)
  print(cnt)
  for num in A:
    print(num) main
# import math
# import itertools
# import numpy as np

def insertionSort(A, n, g, 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

  return [A, cnt]

def shellSort(A, n):
  cnt = 0

  # if n > 4:
  #   G = [4,1]
  # else:
  #   G = [1]

  G = [1]
  i = 1

  while G[0] + 3 ** i < n:
    G.insert(0, G[0] + 3 ** i)
    i += 1

  m = len(G)

  for i in range(m):
    A, cnt = insertionSort(A, n, G[i], cnt)

  return [m, G, A, cnt]

def main():
  n = int(input())
  A = [int(input()) for _ in range(n)]

  m, G, A, cnt = shellSort(A, n)

  print(m)
  print(*G)
  print(cnt)
  for num in A:
    print(num)

if __name__ == '__main__':
  main()
