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 aX) ++ (conv aQ 2 aY) ++ (conv aR 3 (aX+aY)))
        )
        aX
        aY
        0

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

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