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

def shell_sort(a, n)
  $cnt = 0
  $g = []
  h = 0
  (0...n).each do |i|
    h = 3 * h + 1
    break if n < h
    $g.push(h)
  end
  $g.reverse!
  $m = $g.size
  (0...$m).each do |i|
    insertion_sort(a, n, $g[i])
  end
end

n = gets.to_i
a = Array.new(n)

(0...n).each do |i|
  a[i] = gets.to_i
end

shell_sort(a, n)
puts $m
puts $g.join(" ")
puts $cnt
puts a.join("\n")