def insertion_sort(a, n, g)
	for i in g..n-1
		v = a[i]
		j = i - g
		while j >= 0 && a[j] > v
			a[j + g] = a[j]
			j = j - g
			$cnt+=1
		end
		a[j + g] = v
	end
end

def shell_sort(a, n)
	$cnt = 0

	h = Array.new
	h[0] = 1
	i = 1
	while i<100 && h[i-1]<n
		h[i] = 3 * h[i-1] + 1
		if h[i] > n
			break
		end
		i+=1
	end

	m = i
	g = h[0..i-1].reverse
	for i in 0..m-1
		insertion_sort(a, n, g[i])
	end
	
	puts m, g.join(" "),$cnt,a
end

n = gets.chomp.to_i
a = Array.new
n.times { |i|
	a[i] = gets.chomp.to_i
}

shell_sort(a, n)