$cnt = 0
$gell = [1]

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

def shell_sort(a, n)
  h = 1
  loop do
    h = 3 * h + 1
    $gell << h if h <= n
    break if n / 9 < h
  end
  $gell.reverse!
  $gell.each do |g|
    insertion_sort(a, n, g)
  end
end

n = gets.strip.to_i

arr = n.times.map{gets.strip.to_i}

shell_sort(arr, n)
puts $gell.size
puts $gell.join(' ')
puts $cnt
puts arr