import Data.List
import Data.Array.Unboxed
import Debug.Trace

main = do
  n <- (read :: String -> Int) <$> getLine
  a <- sort . map (read :: String -> Int) . words <$> getLine
  b <- sort . map (read :: String -> Int) . words <$> getLine
  c <- sort . map (read :: String -> Int) . words <$> getLine
  let arrA = listArray (0, n-1) a :: UArray Int Int
      arrC = listArray (0, n-1) c :: UArray Int Int
  print $ count arrA arrC b

count :: UArray Int Int -> UArray Int Int -> [Int] -> Int
count a c b = sum $ zipWith (*) (map (lt a) b) (map (gt c) b)

lt :: UArray Int Int -> Int -> Int
lt a b = binSearch b a

gt :: UArray Int Int -> Int -> Int
gt a b = ((+1) . snd . bounds $ a) - (binSearch (b+1) a)

ltList :: [Int] -> [Int] -> [Int]
ltList _  []     = []
ltList [] (b:bs) = 0 : ltList [] bs
ltList a  (b:bs) = let lt = length $ takeWhile (< b) a
                       remain = drop lt a
                   in trace ("a : " ++ (show . length $ a) ++ " " ++ (show . length $ (b:bs))) $ lt : ltList remain bs

gtList :: [Int] -> [Int] -> [Int]
gtList _  []     = []
gtList [] (b:bs) = 0 : gtList [] bs
gtList a  (b:bs) = let le =  length $ takeWhile (<= b) a
                       remain = drop le a
                   in trace ("a : " ++ (show . length $ a) ++ " " ++ (show . length $ (b:bs))) $ (length remain) : gtList remain bs

binSearch :: Int -> UArray Int Int -> Int
binSearch x xs = inner (0-1) (snd $ bounds xs) x xs

inner :: Int -> Int -> Int -> UArray Int Int -> Int
inner lb ub x xs
  | ub - lb > 1 = let mid = lb + (ub - lb) `div` 2
                   in if (xs ! mid) >= x then inner lb mid x xs
                                         else inner mid ub x xs
  | otherwise   = ub
