def insertionSort arr, n, g
	for i in g ... n
		v = arr[i]
		j = i - g
		while j >= 0 && arr[j] > v
			arr[j + g] = arr[j]
			j -= g
			@count += 1
		end
		arr[j + g] = v
	end
end

def shellSort arr, n
	@count = 0

	interval = n / 2
	g = [interval]
	while interval > 1
		interval /= 2
		g << interval
	end	
	m = g.length

	for i in 0 ... m
		insertionSort(arr, n, g[i])
	end

	puts m
	puts g.join(" ")
	puts @count
end

n = gets.to_i
arr = Array.new(n)
n.times{|i| arr[i] = gets.to_i}
shellSort(arr, n)
puts arr