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

    a[j+g] = v
  end

  return a, cnt
end

def shell_sort(a, n)
  g = [1]
  h = 1

  while true do
    break if (h * 3 + 1) > n

    h = h * 3 + 1
    g << h
  end

  m = g.size

  out_a = []
  cnt = 0

  g.reverse!
  m.times do |i|
    out_a, cnt = insertion_sort(a, n, g[i], cnt)
  end

  puts m
  puts g.join(' ')
  puts cnt
  out_a.each { |oa| puts oa }
end

n = gets.to_i
a = (0..n-1).map { |i| gets.to_i }

shell_sort(a, n)
