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

def shell_sort(a, n)
  cnt = 0
  g = []
  h = 1
  while h <= n
    g << h
    h = 3 * h + 1
  end
  g.reverse!
  m = g.length
  puts m
  puts g.join(' ')
  (0..m-1).each do |i|
    cnt += insertion_sort(a, n, g[i])
  end
  puts cnt
end

n = gets.to_i
a = []
n.times{a<<gets.to_i}
shell_sort(a, n)
a.each{|x|puts x}
