import Data.List
import qualified Data.Vector.Unboxed as VU

lowerBound :: VU.Vector Int -> (Int, Int) -> Int -> Int
lowerBound vec (from, to) target
    | from == to = from
    | mValue >= target = lowerBound vec (from, mid) target
    | mValue < target = lowerBound vec (mid + 1, to) target
        where
            mid = (from + to) `quot` 2
            mValue = vec VU.! mid

upperBound :: VU.Vector Int -> (Int, Int) -> Int -> Int
upperBound vec (from, to) target
    | from == to = from
    | mValue > target = upperBound vec (from, mid) target
    | mValue <= target = upperBound vec (mid + 1, to) target
        where
            mid = (from + to) `quot` 2
            mValue = vec VU.! mid

solve :: VU.Vector Int -> VU.Vector Int -> VU.Vector Int -> Int
solve as bs cs
    | VU.null bs = 0 
    | otherwise = res + solve as (VU.tail bs) cs
        where
            res = (lowa) * (lc - uppc)
            b = VU.head bs
            lc = VU.length cs
            lowa = lowerBound as (0, VU.length as) b
            uppc = upperBound cs (0, VU.length cs) b

main = do
    n <- readLn :: IO Int
    as <- sort . map read . words <$> getLine
    bs <- sort . map read . words <$> getLine
    cs <- sort . map read . words <$> getLine
    
    print $ solve (VU.fromList as) (VU.fromList bs) (VU.fromList cs)