params = STDIN.read
l1 = params.split(/\n/)[0].strip
l2 = params.split(/\n/)[1].strip
l3 = params.split(/\n/)[2].strip

n = l1.to_i
v_arr = l2.split(" ")
c_arr = l3.split(" ")

v_with_c = v_arr.zip c_arr
x_minus_y_arr = []
n.times do |j|
  v_with_c.combination(j+1).map do |jews|
    v_tot = jews.map{|jew| jew[0].to_i}.sum
    c_tot = jews.map{|jew| jew[1].to_i}.sum
    x_minus_y_arr << v_tot - c_tot
  end
end


puts x_minus_y_arr.max
