
$cnt = 0
def insertion(a, n, g)
  for i in g...n
    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
end

def shellsort(a, n)
  $cnt = 0
  m = n != 1 ? Math.log2(a.length).ceil: 1
  g = Array.new(m){|i|2 ** i}.reverse
  for i in 0...m
    insertion(a, n, g[i])
  end
  return m, g.join(" "), $cnt
end
arr = []
gets.to_i.times do
  arr << gets.to_i
end
puts shellsort(arr, arr.length),arr