n = gets.to_i
arr = []
n.times do
    arr.push(gets.to_i)
end

cnt = 0
gArr = []
k = 1
while k < n do
    gArr.push(k)
    k = k * 3 + 1
end
gArr.push(1) if gArr.empty?
m = gArr.size
gArr.reverse!

gArr.each do |g|
    for i in g.upto(n - 1) do
        v = arr[i]
        j = i - g
        while j >= 0 && arr[j] > v do
            arr[j + g] = arr[j]
            j = j - g
            cnt += 1
        end
        arr[j + g] = v
    end
end

puts m
puts gArr.join(' ')
puts cnt
puts arr.join("\n")
