module Main where

import           Debug.Trace
import qualified Data.Vector.Unboxed           as VU
import           Data.List

main :: IO ()
main = do
    [aX, aY, aA, aB, aC] <- map read . words <$> getLine :: IO [Int]
    aP                   <- map read . words <$> getLine
    aQ                   <- map read . words <$> getLine
    aR                   <- map read . words <$> getLine

    putStrLn $ show $ sumApple (sortBy
        (\xs ys -> compare (fst ys) (fst xs))
        ((conv aP 1 1) ++ (conv aQ 2 1) ++ (conv aR 3 1))) aX aY 0

conv :: [Int] -> Int -> Int -> [(Int, (Int, Int))]
conv []       _ _ = []
conv (x : []) i c = [(x, (i, c))]
conv (x : xs) i c = (x, (i, c)) : (conv xs i (c + 1))

sumApple :: [(Int,(Int,Int))]->Int->Int->Int->Int
sumApple [] _ _ _ = 0
sumApple (x:xs) tX tY tZ
    |(tX+tY)==tZ         = 0
    |fst (snd x) == 1 = trace "red" $ if tX > 0 then (fst x) + (sumApple xs (tX-1) tY tZ) else sumApple xs tX tY tZ
    |fst (snd x) == 2 = trace "green" $ if tY > 0 then (fst x) + (sumApple xs tX (tY-1) tZ) else sumApple xs tX tY tZ
    |fst (snd x) == 3 = trace "nil" $ if (tX+tY) >= (tZ+1) then (fst x) + (sumApple xs tX tY (tZ+1)) else sumApple xs tX tY tZ
    |otherwise = 0