import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.Set as Set
import qualified Data.Sequence as Sq
import qualified Data.IntMap as IMap
import qualified Data.Vector as V
import Data.Sequence (ViewL(..),ViewR(..),(><),(<|),(|>),Seq)

bsreadInt :: BC.ByteString -> Int
bsreadInt = fst . fromJust . BC.readInt

sqleft :: Seq a -> a
sqleft q = sqleft_(Sq.viewl q)
sqleft_ :: ViewL a -> a
sqleft_ (x :< xs) = x
sqright :: Seq a -> a
sqright q = sqright_(Sq.viewr q)
sqright_ :: ViewR a -> a
sqright_ (xs :> x) = x

--------------------------------------------------------------


sortedlowercount_ :: Array Int Int -> Int -> Int -> Int -> Int
sortedlowercount_ a m n k
  | ((a!c) <=k) && (a!(c+1) > k) = c
  | (a!c) <= k = sortedlowercount_ a c n k
  | otherwise = sortedlowercount_ a m c k
        where c = div (m+n) 2

--ソート済みの配列内でk以下の要素の数
sortedlowercount :: Array Int Int -> Int -> Int -> Int
sortedlowercount a n k = if (a!n) <= k
                         then n
                         else if (a!1) > k
                              then 0
                              else sortedlowercount_ a 1 n k
--ソート済みの配列内でkを超える要素の数
sorteduppercount :: Array Int Int -> Int -> Int -> Int
sorteduppercount a n k = if (a!1) >= k
                         then n
                         else if (a!n) < k
                              then 0
                              else n - (sortedlowercount_ a 1 n k)
                              
main = do
    n <- readLn :: IO Int
    ai <- map bsreadInt . BC.words <$> BC.getLine
    bi <- map bsreadInt . BC.words <$> BC.getLine
    ci <- map bsreadInt . BC.words <$> BC.getLine
    let a = listArray (1,n) (sort ai)
    let b = listArray (1,n) (sort bi)
    let c = listArray (1,n) (sort ci)
    print $ sum [(sortedlowercount a n ((b!i)-1)) * (sorteduppercount c n (b!i)) | i <- [1..n]]