n = gets.to_i
a = Array.new(n).map{gets.to_i}

def generate_G(g,h,n)
  h = 3*h + 1

  if h > n
    return g
  else
    g = g.unshift(h)
    generate_G(g,h,n)
  end

end

def insertion_sort(a,n,g)
  g.upto(n-1) do |i|
    v = a[i]
    j = i-g

    while j >= 0 && a[j] > v
      a[j+g] = a[j]
      j -= g
      $cnt += 1
    end

    a[j+g]=v
  end
end

def shell_sort(a,n)
  $cnt = 0
  $g = generate_G([1],1, n)
  $g.each do |g|
    insertion_sort(a, n, g)
  end
end

shell_sort(a, n)

puts $g.length
puts $g.join(" ")
puts $cnt

a.each{|v| puts v}
