import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    getLine
    as <- sort <$> getIntList
    bs <- sort <$> getIntList
    cs <- sort <$> getIntList
    let ab = zip bs . tail . map fst $ scanl' solveAB (0,as) bs
        bc = map fst $ scanl' solveBC (0,ab) cs
    print $ sum bc

solveAB (k,as) b = let (ts,ds) = span (< b) as in (k + length ts, ds)
solveBC (k,ab) c = let (ts,ds) = span ((< c) . fst) ab in (k + sum (map snd ts), ds)