n = gets.to_i
v = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)

s = [ ]
n.times do |i|
  ooo = v[i] - c[i]
  s.push ooo unless ooo < 0
end

result = [ ]
for x in 1..s.size
  result.concat s.combination(x).map{ |comb| comb.inject(&:+) }
end

p result.empty? ? 0 : result.max
