$cnt = 0
$g = []
 
def i_sort(ca, n)
  c = ca.dup
  n.upto(c.size - 1) do |i|
    v = c[i]
    j = i - n
    while j >= 0 && c[j] > v
      c[j+n] = c[j]
      j -= n
      $cnt += 1
    end
    c[j+n] = v
  end
  c
end
 
def shell_sort(ca)
  m = 1
  n = ca.size / 9
  while m <= n
    m = m * 3 + 1
  end
  while m > 0
    ca = i_sort(ca, m)
    $g << m
    m /= 3
  end
  ca
end
 
gets
arr = shell_sort($<.read.split("\n").map &:to_i)
puts format("%d\n%s\n", $g.size, $g.join(' '))
puts $cnt
puts arr