import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Data.Array
import Data.Maybe
import Data.List

type S = Array Int Int

-- 下限境界 (Array 付き)
lowerBoundA :: Array Int Int -> (Int, Int) -> Int -> Int
lowerBoundA arr (from, to) target
    | from == to = from
    | mValue >= target = lowerBoundA arr (from, mid) target
    | mValue < target = lowerBoundA arr (mid + 1, to) target
        where
            mid = (from + to) `div` 2
            mValue = arr ! mid

-- 上限境界 (Array 付き)
upperBoundA :: Array Int Int -> (Int, Int) -> Int -> Int
upperBoundA arr (from, to) target
    | from == to = from
    | mValue > target = upperBoundA arr (from, mid) target
    | mValue <= target = upperBoundA arr (mid + 1, to) target
        where
            mid = (from + to) `div` 2
            mValue = arr ! mid

solve :: S -> S -> S -> Int -> Int -> Int 
solve xs ys zs n i
  | i >= n = 0
  | otherwise = res + solve xs ys zs n (i+1)
    where
      res = lb * (n - ub)
      y = ys ! i
      lb = lowerBoundA xs (0,n) y
      ub = upperBoundA zs (0,n) y

main = do
  n <- readLn :: IO Int
  xs <- listArray (0,n-1) . sort . map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO S
  ys <- listArray (0,n-1) . sort . map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO S
  zs <- listArray (0,n-1) . sort . map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO S
  print $ solve xs ys zs n 0