$cnt = 0

def insertion_sort(a, n, g)
    (g..n-1).each{|i|
        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

class Array
    def sorted?
        (1...self.size).all?{|i| self[i-1]<=self[i]}
    end
end

def shell_sort(a, n)
    m = 0
    g = [1]
    loop do
        nxt = 3 * g[-1] + 1
        break if nxt >= n
        g << nxt
    end
    g.reverse!
    m = g.size
    g.each{|gi|
        insertion_sort(a, n, gi)
    }
    return g
end

n = gets.to_i
a = n.times.map{gets.to_i}

g = shell_sort(a, n)
puts g.size, g.join(' '), $cnt, a

