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

type Array a = IOArray Int a

main :: IO ()
main = do
    n  <- read <$> getLine :: IO Int
    as <- newListArray (0,n-1) . sort . map read . words =<< getLine :: IO (Array Int)
    bs <- map read . words <$> getLine :: IO [Int]
    cs <- newListArray (0,n-1) . sort . map read . words =<< getLine :: IO (Array Int)
    ns <- forM bs (\x -> do
        l <- lowerBound as x
        u <- (sub n) <$>  upperBound cs x
        -- putStrLn (show l ++ " " ++ show u)
        return $ l * u)
    print $ sum ns

sub :: Int -> Int -> Int
sub = (-)

lowerBound' :: Array Int
            -> (Int, Int)
            -> Int
            -> IO Int
lowerBound' arr (first, last) n = do
    fc <- arr!first     
    mc <- arr!mid     
    if last - first <= 1
        then return $ if fc < n then last else first
        else if mc < n
            then lowerBound' arr (mid, last)  n
            else lowerBound' arr (first, mid) n
    where
    mid = div (first+last) 2

lowerBound :: Array Int
            -> Int
            -> IO Int
lowerBound arr n = do
    (start, last) <- getBounds arr
    lc <- arr!last
    if lc < n then return $ last+1
              else lowerBound' arr (start, last) n

upperBound :: Array Int -> Int -> IO Int
upperBound arr n = lowerBound arr (n+1)

(!) :: (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 (<<-) #-}
 