import Control.Monad
import Data.List

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

solve n ps js = f n (sum ps) (reverse $ sort js)
 where
  f n m [] = n*m
  f n m (j:js) = (n*m) `max` f (n-1) (m+j) js

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