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
  
    g = []
    interval = 1
    begin
        g << interval
        interval = g.last * 2 + 1
    end while interval < n
    g.reverse!
    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