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

def shellSort(a,n,m,g)
    cnt = 0
    for i in 0..m-1 do
        cnt+=insertionSort(a, n, g[i])
    end
    return cnt
end

n=gets.to_i
a=Array.new
for i in 1..n do
  a.push(gets.to_i)
end

m = (Math.log10(2*n+1)/Math.log10(3)).floor
g = Array.new
for i in 1..m do
   g.push((3**i-1)/2)
end
g.reverse!
cnt=shellSort(a,n,m,g)

p m
printf("%s\n",g.join(" "))
p cnt
a.each{|v|
  p v
}