import Data.List
import qualified Data.Set as Set

main :: IO ()
main = do
    n <- readLn :: IO Int
    [a,b,c] <- map (sort . (map read . words)) . lines <$> getContents :: IO [[Int]]
    let b' = map (\i -> Set.size . snd . Set.split i $ Set.fromList c) b :: [Int]
        b'' = zip b b'
    print $ sum [bj | ai <- a, (bi, bj) <- b'', ai < bi]
