def insertion_sort a, n, g
  g.upto(n-1) do |i|
    k = a[i]
    j = i - g
    while j >= 0 && k < a[j]
      a[j+g] = a[j]
      $cnt += 1
      j -= g
    end
    a[j+g] = k
  end

  a
end

def calc_ms n
  ms = []
  c = 0
  i = 1
  while c < 100 && i <= n
    ms << i
    i = 3 * i + 1
    c += 1
  end

  return c, ms.reverse
end

len = gets.to_i
arr = readlines.map(&:chomp).map(&:to_i)
$cnt = 0

m_length, ms = calc_ms len
ms.each do |m|
#  arr = insertion_sort arr, len, m
  insertion_sort arr, len, m
end

puts m_length
puts ms.join(" ")
puts $cnt
puts arr.join("\n")
