n = gets.to_i
arr = []
n.times { arr << gets.to_i }
$count = 0

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

def shell_sort(n, arr)
  g = num_line(n)
  m = g.size

  (0..(m - 1)).reverse_each do |i|
    insertion_sort(n, arr, g[i])
  end

  puts m
  puts g.reverse.join(' ')
  puts $count
  arr.each do |e|
    puts e
  end
end

def num_line(n)
  g = []
  i = 0
  num = 0
  while(n > num) do
    num = num * 3 + 1
    break if(num > n)
    g <<  num
    i += 1
  end
  g
end

shell_sort(n, arr)

