import Control.Monad
import Data.Maybe
import Control.Applicative

total :: [Int] -> [Int] -> Maybe Int
total [] _ = Nothing
total _ [] = Nothing
total pcbe hg = Just (mPCBE + mHG)
  where mPCBE = sum pcbe - minimum pcbe
        mHG   = maximum hg


main :: IO()
main = do
  pcbe <- map (read :: String -> Int) <$> replicateM 4 getLine
  hg <- map (read :: String -> Int) <$> replicateM 2 getLine
  print $ fromJust $ total pcbe hg