# ALDS1_2_D Shell Sort
n = gets.chomp.to_i
a = []
$cnt = 0
n.times do
  a << gets.chomp.to_i
end

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

$gg = [1]
h = $gg[0]
while true
  h = h * 3 + 1
  break if h > n
  $gg << h
end
$gg.reverse!

def shellSort(a, n)
  $gg.each do |i|
    insertionSort(a, n, i)
  end
end

shellSort(a, n)

puts $gg.length
puts $gg.join(" ")
puts $cnt
puts a