n = gets.chomp.to_i
v = gets.chomp.split(" ").map(&:to_i)
c = gets.chomp.split(" ").map(&:to_i)
ans = -100000000
["1","0"].repeated_permutation (n) do |i|
    cost = 0
    kati = 0
    sa = 0
    i.each_with_index do |item,j|
        if item == "1"
            cost += c[j]
            kati += v[j]
        end
    end
    sa = kati - cost
    ans = [ans,sa].max
end
puts ans