import Data.List
import Data.Array.IO
import Control.Monad
import qualified Data.Array.IO as A

type Array = IOArray Int

main :: IO () 
main = do
    n  <- read <$> getLine 
    as <- newListArray (1, n) . sort . map read . words =<< getLine  :: IO (Array Int)
    bs <- newListArray (1, n) . sort . map read . words =<< getLine  :: IO (Array Int)
    cs <- newListArray (1, n) . sort . map read . words =<< getLine :: IO (Array Int)

    {-
    putStr "as: "
    forM_ [1..n] $ \i -> putStr . (++" ") . show =<< (as!i) 
    putStrLn ""
    
    putStr "bs: "
    forM_ [1..n] $ \i -> putStr . (++" ") . show =<< (bs!i) 
    putStrLn ""

    putStr "cs: "
    forM_ [1..n] $ \i -> putStr . (++" ") . show =<< (cs!i) 
    putStrLn ""
    -}

    ns <- forM [1..n] $ \i -> do
       x <- (bs!i)
       ai <- binary_search as x
       ci <- (n -) <$> binary_searchU cs x
       -- putStr . (++ ": ") . show $ (ai ,ci)
       -- print $ ai * ci
       return $ ai * ci

    print $ sum ns

    return ()

sub = (-)

binary_searchU :: Array Int
              -> Int
              -> IO Int
binary_searchU arr n = do
    (s, l) <- getBounds arr

    sc <- arr ! s
    lc <- arr ! l

    case (sc > n, lc < n) of
        (True, _) -> return $ 0
        (_, True) -> return $ l
        (_,    _) -> binary_searchU' arr n (s, l)

binary_searchU' :: Array Int 
               -> Int
               -> (Int, Int) -- 区間
               -> IO Int
binary_searchU' arr n (s, l) = do
    -- print (s, l)
    let a = (s+l) `div` 2
    n'  <- arr ! a
    case (n>=n') of
        True -> if a==s then return s
                        else binary_searchU' arr n (a, l)
        False-> if a==l then return s
                        else binary_searchU' arr n (s, a)

binary_search :: Array Int
              -> Int
              -> IO Int
binary_search arr n = do
    (s, l) <- getBounds arr

    sc <- arr ! s
    lc <- arr ! l

    case (sc > n, lc < n) of
        (True, _) -> return $ 0
        (_, True) -> return $ l
        (_,    _) -> binary_search' arr n (s, l)

binary_search' :: Array Int 
               -> Int
               -> (Int, Int) -- 区間
               -> IO Int
binary_search' arr n (s, l) = do
    -- print (s, l)
    let a = (s+l) `div` 2
    n'  <- arr ! a
    case (n>n') of
        True -> if a==s then return s
                        else binary_search' arr n (a, l)
        False-> if a==l then return s
                        else binary_search' arr n (s, a)

(!) :: (A.Ix x) => A.IOArray x y -> x -> IO y
arr ! n = A.readArray arr n
{-# INLINE (!) #-}
 
(!?) :: (A.Ix x) => A.IOArray x y -> x -> IO (Maybe y)
arr !? n = do
    (start, last) <- A.getBounds arr
    if n >= start && last >= n 
        then Just <$> A.readArray arr n 
        else return Nothing
{-# INLINE (!?) #-}
 
(<<-) :: (A.Ix x) => (A.IOArray x y, x) -> y -> IO ()
(arr, i) <<- v = A.writeArray arr i v
{-# INLINE (<<-) #-}
 