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 = (+1) $ upperBound b a

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

--[lb, ub) x未満のmax
upperBound :: Int -> UArray Int Int -> Int
upperBound x xs = innerUB (0-1) ((+1) . snd $ bounds xs) x xs

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

--(lb, ub] xより大きいmin
lowerBound :: Int -> UArray Int Int -> Int
lowerBound x xs = innerLB (0-1) ((+1) . snd $ bounds xs) x xs

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