N = gets.chomp.to_i
V = gets.chomp.split(" ").map(&:to_i)
C = gets.chomp.split(" ").map(&:to_i)
vPatterns = []
cPatterns = []


(N+1).times do |i|
  V.combination(i){|vPattern| vPatterns << vPattern }
  C.combination(i){|cPattern| cPatterns << cPattern }
end

max = 0
patternsLen = vPatterns.length

patternsLen.times do |j|
  x = 0
  y = 0
  vPattern = vPatterns[j]
  cPattern = cPatterns[j]
  patternLen = vPattern.length
  if vPattern == [] && cPattern == []
    max = 0
    next
  end
  patternLen.times do |k|
    x += vPattern[k]
    y += cPattern[k]
  end 
  max = x-y if x-y > max
end
puts max
