import Data.List
import Data.Array.IO
import Debug.Trace
import Control.Monad

type Arr = IOUArray Int Int

main :: IO ()
main = do
  n <- readLn :: IO Int
  _as <- (sort . map read . words) <$> getLine :: IO [Int]
  _bs <- (sort . map read . words) <$> getLine :: IO [Int]
  _cs <- (sort . map read . words) <$> getLine :: IO [Int]
  as <- newListArray (0, n - 1) _as :: IO Arr
  bs <- newListArray (0, n - 1) _bs :: IO Arr
  cs <- newListArray (0, n - 1) _cs :: IO Arr
  print =<< solve as bs cs

solve :: Arr -> Arr -> Arr -> IO Int
solve as bs cs = do
  bList <- getElems bs
  counts <- forM bList $ \b -> solveB as b cs
  return $ sum counts

solveB :: Arr -> Int -> Arr -> IO Int
solveB as b cs = do
  upperA <- upperBound as b
  lowerC <- lowerBound cs b
  (sC, eC) <- getBounds cs
  return ((upperA + 1) * (eC - lowerC + 1))

upperBound :: Arr -> Int -> IO Int
upperBound arr k = do
  (s, e) <- getBounds arr
  let len = e - s + 1
  _upperBound (-1) len
  where
    _upperBound :: Int -> Int -> IO Int
    _upperBound left right
      | right - left <= 1 = return left
      | otherwise = do
          let center = (left + right) `div` 2
          cVal <- readArray arr center
          if k < cVal
            then _upperBound left center
            else _upperBound center right

lowerBound :: Arr -> Int -> IO Int
lowerBound arr k = do
  (s, e) <- getBounds arr
  let len = e - s + 1
  _lowerBound (-1) len
    where
      _lowerBound :: Int -> Int -> IO Int
      _lowerBound left right
        | right - left <= 1 = return right
        | otherwise = do
            let center = (left + right) `div` 2
            cVal <- readArray arr center
            if cVal < k
              then _lowerBound center right
              else _lowerBound left center