N = gets.to_i
V = gets.split.map(&:to_i)
C = gets.split.map(&:to_i)

ans = 0
1.upto(N) do |n|
  (0..N-1).to_a.combination(n) do |c|
    x = 0
    y = 0
    c.each do |i|
      x += V[i]
      y += C[i]
    end

    ans = x - y if x - y > ans
  end
end

puts ans
