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

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

v_with_c = v_arr.zip c_arr
ans = 0
n.times do |j|
  v_with_c.combination(j+1).map do |jews|
    v_tot = jews.map{|jew| jew[0]}.inject(:+)
    c_tot = jews.map{|jew| jew[1]}.inject(:+)
    tryal = v_tot - c_tot
    ans = tryal if ans < tryal
  end
end


puts ans
