import io.StdIn._

object Main extends App {
  val n = readInt()
  val v = readLine().split(" ").map(_.toInt).toSeq
  val c = readLine().split(" ").map(_.toInt).toSeq

  require(1 <= n && n <= 20)
  require(v.forall(i => 1 <= i && i <= 50))
  require(c.forall(i => 1 <= i && i <= 50))

  println((0 to n).flatMap(i => v.zip(c).combinations(i).map(_.map(j => j._1 - j._2).sum)).max)
}
