import Control.Monad

solve a n [] _ = a * n
solve a n [p] _ = (a+p) * (n+1)
solve a n (p:ps@(q:qs)) (j:js) 
 = solve (a+p+j+q) (n+1) qs js `max` solve (a+p) (n+1) ps js

getNums = getLine >>= return . map read . words

main = do
 n <- getLine
 when (n /= "0") $ do
  ps <- getNums
  js <- getNums
  print $ solve 0 0 ps js
  main