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

f [] _ _ = []
f (b:bs) [] n = 0 : (f bs [] n)
f (b:bs) (c:cs) n
  | b < c = n : (f bs (c:cs) n)
  | b >= c = (f (b:bs) cs (n-1))

g [] _ _ = []
g (a:as) [] [] = 0 : (g as [] [])
g (a:as) (b:bs) (b':bs')
  | a < b = b' : (g as (b:bs) (b':bs'))
  | a >= b = (g (a:as) bs bs')

main = do
  n <- readLn :: IO Int
  a <- BS.getLine >>= return . sort . (map (fst . fromJust . BS.readInt)) . BS.words :: IO [Int]
  b <- BS.getLine >>= return . sort . (map (fst . fromJust . BS.readInt)) . BS.words :: IO [Int]
  c <- BS.getLine >>= return . sort . (map (fst . fromJust . BS.readInt)) . BS.words :: IO [Int]

  let b' = (reverse . tail . (scanl (+) 0) .  reverse) $ f b c (length c)

  print $ sum $ g a b b'
